--- jpake.c.orig	2016-03-02 16:33:13.494032268 -0800
+++ jpake.c	2016-03-02 16:34:37.809748362 -0800
@@ -116,6 +116,8 @@
                          const BIGNUM *secret)
 {
     JPAKE_CTX *ctx = OPENSSL_malloc(sizeof *ctx);
+    if (ctx == NULL)
+	return NULL;
 
     JPAKE_CTX_init(ctx, name, peer_name, p, g, q, secret);
 
@@ -150,6 +152,8 @@
 {
     size_t l = BN_num_bytes(bn);
     unsigned char *bin = OPENSSL_malloc(l);
+    if (bin == NULL)
+	return NULL; /* oops, memory allocation failed... */
 
     hashlength(sha, l);
     BN_bn2bin(bn, bin);
