DRBG: fix memory leak on error in rand_drbg_get_entropy()
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Sun, 8 Apr 2018 10:09:10 +0000 (12:09 +0200)
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Tue, 10 Apr 2018 08:33:17 +0000 (10:33 +0200)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5918)

crypto/rand/rand_lib.c

index 3589e75..6e98e4d 100644 (file)
@@ -229,7 +229,7 @@ size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
              */
             RANDerr(RAND_F_RAND_DRBG_GET_ENTROPY,
                     RAND_R_PREDICTION_RESISTANCE_NOT_SUPPORTED);
-            return 0;
+            goto err;
         }
 
         /* Get entropy by polling system entropy sources. */
@@ -241,6 +241,7 @@ size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
         *pout = rand_pool_detach(pool);
     }
 
+ err:
     rand_pool_free(pool);
     return ret;
 }