Skip to content

Commit a3fcf41

Browse files
committed
Check memory allocation
1 parent e00caac commit a3fcf41

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

script.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ static PKCS7 *script_pkcs7_extract(FILE_FORMAT_CTX *ctx)
353353
if (ctx->script_ctx->utf == 8) {
354354
base64_len = signature_len;
355355
base64_data = OPENSSL_malloc(base64_len);
356+
if (!base64_data)
357+
return NULL; /* memory allocation failed */
356358
memcpy(base64_data, signature_data, base64_len);
357359
} else {
358360
base64_len = utf16_to_utf8((const void *)signature_data,
@@ -691,6 +693,8 @@ static int write_commented(FILE_FORMAT_CTX *ctx, BIO *outdata, const char *data,
691693
* - closing tag
692694
* - trailing NUL ("\0") */
693695
line = OPENSSL_malloc(2 + open_tag_len + length + close_tag_len + 1);
696+
if (!line)
697+
return 0; /* memory allocation failed */
694698
strcpy(line, "\r\n");
695699
strcat(line, open_tag);
696700
memcpy(line + 2 + open_tag_len, data, length);

0 commit comments

Comments
 (0)