fix potential memory leak + improved error checking
authorNils Larsch <nils@openssl.org>
Fri, 5 Aug 2005 14:39:11 +0000 (14:39 +0000)
committerNils Larsch <nils@openssl.org>
Fri, 5 Aug 2005 14:39:11 +0000 (14:39 +0000)
PR: 1182

crypto/x509v3/v3_cpols.c

index 0d554f3a2c97f81b8595b186d033b8aa88ec2c5e..867525f336a19b00d250bc1484434ee27605f730 100644 (file)
@@ -137,7 +137,15 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method,
        CONF_VALUE *cnf;
        int i, ia5org;
        pols = sk_POLICYINFO_new_null();
+       if (pols == NULL) {
+               X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_MALLOC_FAILURE);
+               return NULL;
+       }
        vals =  X509V3_parse_list(value);
+       if (vals == NULL) {
+               X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_X509V3_LIB);
+               goto err;
+       }
        ia5org = 0;
        for(i = 0; i < sk_CONF_VALUE_num(vals); i++) {
                cnf = sk_CONF_VALUE_value(vals, i);
@@ -176,6 +184,7 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method,
        sk_CONF_VALUE_pop_free(vals, X509V3_conf_free);
        return pols;
        err:
+       sk_CONF_VALUE_pop_free(vals, X509V3_conf_free);
        sk_POLICYINFO_pop_free(pols, POLICYINFO_free);
        return NULL;
 }