Add lots of checks for memory allocation failure, error codes to indicate
[openssl.git] / crypto / x509v3 / v3_bitst.c
index 42d5f8beffdcbe1f5f4570d28f3f65a196046b87..170c8d280bcc104a15166ac6413b3b14acd1d0ee 100644 (file)
@@ -118,7 +118,12 @@ ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
                for(bnam = method->usr_data; bnam->lname; bnam++) {
                        if(!strcmp(bnam->sname, val->name) ||
                                !strcmp(bnam->lname, val->name) ) {
-                               ASN1_BIT_STRING_set_bit(bs, bnam->bitnum, 1);
+                               if(!ASN1_BIT_STRING_set_bit(bs, bnam->bitnum, 1)) {
+                                       X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,
+                                               ERR_R_MALLOC_FAILURE);
+                                       M_ASN1_BIT_STRING_free(bs);
+                                       return NULL;
+                               }
                                break;
                        }
                }