In cases where we ask PEM_def_callback for minimum 0 length, accept 0 length
[oweals/openssl.git] / crypto / x509 / by_dir.c
index 90a3784858218b4d8bae38ad94bcf08395ecacd6..6f0209a275ef33f34331835f525d600248edf268 100644 (file)
@@ -401,6 +401,11 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
             }
             if (!hent) {
                 hent = OPENSSL_malloc(sizeof(BY_DIR_HASH));
+                if (hent == NULL) {
+                    CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
+                    X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE);
+                    goto finish;
+                }
                 hent->hash = h;
                 hent->suffix = k;
                 if (!sk_BY_DIR_HASH_push(ent->hashes, hent)) {
@@ -424,8 +429,8 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
              * If we were going to up the reference count, we would need to
              * do it on a perl 'type' basis
              */
-        /*-             CRYPTO_add(&tmp->data.x509->references,1,
-                                CRYPTO_LOCK_X509);*/
+        /*- CRYPTO_add(&tmp->data.x509->references,1,
+                    CRYPTO_LOCK_X509);*/
             goto finish;
         }
     }