]> granicus.if.org Git - openssl/commitdiff
Avoid possible memory leak.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 14 Feb 2005 21:54:29 +0000 (21:54 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 14 Feb 2005 21:54:29 +0000 (21:54 +0000)
crypto/pkcs7/pk7_smime.c

index ff0d406b8b86a54611d29e0d394d649d52e1e190..a852b4923586d2593a6fa90efe6947d66b39b249 100644 (file)
@@ -325,10 +325,6 @@ STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
                PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_WRONG_CONTENT_TYPE);
                return NULL;
        }
-       if(!(signers = sk_X509_new_null())) {
-               PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,ERR_R_MALLOC_FAILURE);
-               return NULL;
-       }
 
        /* Collect all the signers together */
 
@@ -339,6 +335,11 @@ STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
                return 0;
        }
 
+       if(!(signers = sk_X509_new_null())) {
+               PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,ERR_R_MALLOC_FAILURE);
+               return NULL;
+       }
+
        for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++)
        {
            si = sk_PKCS7_SIGNER_INFO_value(sinfos, i);