--- pmeth_gn.c.orig	2016-03-05 06:15:29.530259070 -0800
+++ pmeth_gn.c	2016-03-05 06:18:17.940663167 -0800
@@ -152,6 +152,11 @@
     if (!*ppkey)
         *ppkey = EVP_PKEY_new();
 
+    if (*ppkey == NULL) {
+	EVPerr(EVP_F_EVP_PKEY_PARAMGEN, ERR_R_MALLOC_FAILURE);
+	return -1;
+    }
+
     ret = ctx->pmeth->keygen(ctx, *ppkey);
     if (ret <= 0) {
         EVP_PKEY_free(*ppkey);
