Fix i2d_X509_AUX: pp can be NULL.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 2 May 2016 16:33:50 +0000 (17:33 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 2 May 2016 21:46:39 +0000 (22:46 +0100)
Reported by David Benjamin

Reviewed-by: Emilia Käsper <emilia@openssl.org>
crypto/x509/x_x509.c

index 11e758be807648481e83e385f801dc1ab05df3df..043ab0786663d86ae787682e52fb36af725dce25 100644 (file)
@@ -184,14 +184,15 @@ X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length)
 int i2d_X509_AUX(X509 *a, unsigned char **pp)
 {
     int length, tmplen;
-    unsigned char *start = *pp;
+    unsigned char *start = pp != NULL ? *pp : NULL;
     length = i2d_X509(a, pp);
     if (length < 0 || a == NULL)
         return length;
 
     tmplen = i2d_X509_CERT_AUX(a->aux, pp);
     if (tmplen < 0) {
-        *pp = start;
+        if (start != NULL)
+            *pp = start;
         return tmplen;
     }
     length += tmplen;