From c269da78697e18af4d11659931d010f6de2dbc85 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 25 May 2022 15:34:57 -0400 Subject: [PATCH] swtpm_cert: Test for NULL pointer returned by malloc Signed-off-by: Stefan Berger --- src/swtpm_cert/ek-cert.c | 4 ++++ 1 file changed, 4 insertions(+) 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 @@ hex_str_to_bin(const char *hexstr, int *modulus_len) } 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;