diff options
Diffstat (limited to 'crypto/txt_db/txt_db.c')
-rw-r--r-- | crypto/txt_db/txt_db.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/crypto/txt_db/txt_db.c b/crypto/txt_db/txt_db.c index 029d0bb2fe..49d8ccc246 100644 --- a/crypto/txt_db/txt_db.c +++ b/crypto/txt_db/txt_db.c @@ -71,7 +71,6 @@ const char TXT_DB_version[] = "TXT_DB" OPENSSL_VERSION_PTEXT; TXT_DB *TXT_DB_read(BIO *in, int num) { TXT_DB *ret = NULL; - int er = 1; int esc = 0; long ln = 0; int i, add, n; @@ -161,36 +160,23 @@ TXT_DB *TXT_DB_read(BIO *in, int num) "wrong number of fields on line %ld (looking for field %d, got %d, '%s' left)\n", ln, num, n, f); #endif - er = 2; goto err; } pp[n] = p; - if (!sk_OPENSSL_PSTRING_push(ret->data, pp)) { -#if !defined(OPENSSL_NO_STDIO) /* temporary fix :-( */ - fprintf(stderr, "failure in sk_push\n"); -#endif - er = 2; + if (!sk_OPENSSL_PSTRING_push(ret->data, pp)) goto err; - } } - er = 0; + BUF_MEM_free(buf); + return ret; err: BUF_MEM_free(buf); - if (er) { -#if !defined(OPENSSL_NO_STDIO) - if (er == 1) - fprintf(stderr, "OPENSSL_malloc failure\n"); -#endif - if (ret != NULL) { - if (ret->data != NULL) - sk_OPENSSL_PSTRING_free(ret->data); - OPENSSL_free(ret->index); - OPENSSL_free(ret->qual); - OPENSSL_free(ret); - } - return (NULL); - } else - return (ret); + if (ret != NULL) { + sk_OPENSSL_PSTRING_free(ret->data); + OPENSSL_free(ret->index); + OPENSSL_free(ret->qual); + OPENSSL_free(ret); + } + return (NULL); } OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, @@ -242,8 +228,7 @@ int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *), return (0); } } - if (db->index[field] != NULL) - lh_OPENSSL_STRING_free(db->index[field]); + lh_OPENSSL_STRING_free(db->index[field]); db->index[field] = idx; db->qual[field] = qual; return (1); @@ -292,8 +277,7 @@ long TXT_DB_write(BIO *out, TXT_DB *db) } ret = tot; err: - if (buf != NULL) - BUF_MEM_free(buf); + BUF_MEM_free(buf); return (ret); } @@ -343,8 +327,7 @@ void TXT_DB_free(TXT_DB *db) if (db->index != NULL) { for (i = db->num_fields - 1; i >= 0; i--) - if (db->index[i] != NULL) - lh_OPENSSL_STRING_free(db->index[i]); + lh_OPENSSL_STRING_free(db->index[i]); OPENSSL_free(db->index); } OPENSSL_free(db->qual); |