From d5ecafc334aeb333a274ec19b19b92dd261ae8fb Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Fri, 20 Mar 2020 17:12:18 +0100 Subject: [PATCH] fixed memory leak fixes https://oss-fuzz.com/testcase-detail/5084702283399168 --- src/libopensc/ef-atr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libopensc/ef-atr.c b/src/libopensc/ef-atr.c index edbf4410..1a20c8d2 100644 --- a/src/libopensc/ef-atr.c +++ b/src/libopensc/ef-atr.c @@ -148,7 +148,7 @@ int sc_parse_ef_atr(struct sc_card *card) sc_format_path("3F002F01", &path); rv = sc_select_file(card, &path, &file); - LOG_TEST_RET(ctx, rv, "Cannot select EF(ATR) file"); + LOG_TEST_GOTO_ERR(ctx, rv, "Cannot select EF(ATR) file"); if (file->size) { size = file->size; @@ -156,8 +156,10 @@ int sc_parse_ef_atr(struct sc_card *card) size = 1024; } buf = malloc(size); - if (!buf) - LOG_TEST_GOTO_ERR(ctx, SC_ERROR_OUT_OF_MEMORY, "Memory allocation error"); + if (!buf) { + rv = SC_ERROR_OUT_OF_MEMORY; + LOG_TEST_GOTO_ERR(ctx, rv, "Memory allocation error"); + } rv = sc_read_binary(card, 0, buf, size, 0); LOG_TEST_GOTO_ERR(ctx, rv, "Cannot read EF(ATR) file");