x509v3/v3_utl.c: avoid double-free.
authorAndy Polyakov <appro@openssl.org>
Sat, 14 Oct 2017 08:21:19 +0000 (10:21 +0200)
committerAndy Polyakov <appro@openssl.org>
Tue, 17 Oct 2017 19:36:31 +0000 (21:36 +0200)
Thanks to David Benjamin for spotting this.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4532)

crypto/x509v3/v3_utl.c

index a839861dbaade9507eb4c0aba930761c7bbfee81..4dbcfaa430795c7c9fce4acb249982a06a981051 100644 (file)
@@ -56,8 +56,10 @@ int X509V3_add_value(const char *name, const char *value,
     return 1;
  err:
     X509V3err(X509V3_F_X509V3_ADD_VALUE, ERR_R_MALLOC_FAILURE);
-    if (sk_allocated)
+    if (sk_allocated) {
         sk_CONF_VALUE_free(*extlist);
+        *extlist = NULL;
+    }
     OPENSSL_free(vtmp);
     OPENSSL_free(tname);
     OPENSSL_free(tvalue);