diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2016-10-02 14:13:40 +0100 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2016-10-17 14:34:00 +0100 |
commit | 6215f27a83c6b9089a217dd6deab1665e0ced516 (patch) | |
tree | 7385937a786ba409f7ef88146fd272edc279ade1 /crypto/asn1/asn1_lib.c | |
parent | ba6017a19346a169ca09bb67427ccf6fc56af0af (diff) |
Fix embedded string handling.
Don't rely on embedded flag to free strings correctly: it wont be
set if there is a malloc failure during initialisation.
Thanks to Guido Vranken for reporting this issue.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1725)
Diffstat (limited to 'crypto/asn1/asn1_lib.c')
-rw-r--r-- | crypto/asn1/asn1_lib.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c index 9dfe395399..8ca53b4ce4 100644 --- a/crypto/asn1/asn1_lib.c +++ b/crypto/asn1/asn1_lib.c @@ -11,6 +11,7 @@ #include <limits.h> #include "internal/cryptlib.h" #include <openssl/asn1.h> +#include "asn1_locl.h" static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, long max); @@ -314,16 +315,23 @@ ASN1_STRING *ASN1_STRING_type_new(int type) return (ret); } -void ASN1_STRING_free(ASN1_STRING *a) +void asn1_string_embed_free(ASN1_STRING *a, int embed) { if (a == NULL) return; if (!(a->flags & ASN1_STRING_FLAG_NDEF)) OPENSSL_free(a->data); - if (!(a->flags & ASN1_STRING_FLAG_EMBED)) + if (embed == 0) OPENSSL_free(a); } +void ASN1_STRING_free(ASN1_STRING *a) +{ + if (a == NULL) + return; + asn1_string_embed_free(a, a->flags & ASN1_STRING_FLAG_EMBED); +} + void ASN1_STRING_clear_free(ASN1_STRING *a) { if (a == NULL) |