PROV: check for memory allocation failure in digest _dupctx.
authorPauli <paul.dale@oracle.com>
Wed, 20 Nov 2019 20:47:57 +0000 (06:47 +1000)
committerPauli <paul.dale@oracle.com>
Fri, 22 Nov 2019 05:20:54 +0000 (15:20 +1000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10487)

providers/common/include/prov/digestcommon.h

index 868cbbf79f0f69681f2b577a039472d3f1da8d45..e5b76ff49f06efb5fb17d5d95a6a1436f3537c15 100644 (file)
@@ -49,7 +49,8 @@ static void *name##_dupctx(void *ctx)                                          \
 {                                                                              \
     CTX *in = (CTX *)ctx;                                                      \
     CTX *ret = OPENSSL_malloc(sizeof(*ret));                                   \
-    *ret = *in;                                                                \
+    if (ret != NULL)                                                           \
+        *ret = *in;                                                            \
     return ret;                                                                \
 }                                                                              \
 static OSSL_OP_digest_final_fn name##_internal_final;                          \