From 3e1b041ff866f915c58f05c3b6a63310b81b676f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 8 Apr 2021 10:37:33 +0200 Subject: [PATCH] fix coverity CID 317346 --- client/src/cmdsmartcard.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/cmdsmartcard.c b/client/src/cmdsmartcard.c index 00d730d62..1b89b7301 100644 --- a/client/src/cmdsmartcard.c +++ b/client/src/cmdsmartcard.c @@ -434,6 +434,7 @@ static int CmdSmartRaw(const char *Cmd) { uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t)); if (buf == NULL) { PrintAndLogEx(DEBUG, "failed to allocate memory"); + free(payload); return PM3_EMALLOC; } @@ -447,6 +448,7 @@ static int CmdSmartRaw(const char *Cmd) { // reading response from smart card int len = smart_response(buf, PM3_CMD_DATA_SIZE); if (len < 0) { + free(payload); free(buf); return PM3_ESOFT; } @@ -1140,6 +1142,7 @@ int ExchangeAPDUSC(bool verbose, uint8_t *datain, int datainlen, bool activateCa int len = smart_responseEx(dataout, maxdataoutlen, verbose); if (len < 0) { + free(payload); return 1; } @@ -1158,7 +1161,6 @@ int ExchangeAPDUSC(bool verbose, uint8_t *datain, int datainlen, bool activateCa } free(payload); - *dataoutlen = len; return 0; }