swtpm_cert: Test for NULL pointer returned by malloc

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
diff --git a/src/swtpm_cert/ek-cert.c b/src/swtpm_cert/ek-cert.c
index b66e1a4..eec5c70 100644
--- a/src/swtpm_cert/ek-cert.c
+++ b/src/swtpm_cert/ek-cert.c
@@ -197,6 +197,10 @@
     }
 
     result = malloc(len / 2);
+    if (result == NULL) {
+        fprintf(stderr, "Out of memory tring to allocated %d bytes.", len / 2);
+        return NULL;
+    }
     i = 0;
     j = 0;