Fix possible memory leak.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 14 Feb 2005 21:53:24 +0000 (21:53 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 14 Feb 2005 21:53:24 +0000 (21:53 +0000)
crypto/pkcs7/pk7_smime.c

index f22c07fb55ac7b3b385b37b997065a94bc9ec38d..4607e5fd6990f8d2a01b3c49f21c766d8a2e6fd1 100644 (file)
@@ -3,7 +3,7 @@
  * project.
  */
 /* ====================================================================
  * project.
  */
 /* ====================================================================
- * Copyright (c) 1999-2003 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -329,10 +329,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;
        }
                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 */
 
 
        /* Collect all the signers together */
 
@@ -343,6 +339,11 @@ STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
                return 0;
        }
 
                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);
        for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++)
        {
            si = sk_PKCS7_SIGNER_INFO_value(sinfos, i);