From 0f5a58fa50508a1ffa5622765024a6c28695b270 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Wed, 21 Dec 2016 01:42:08 +0200 Subject: [PATCH] Fix a memory leak when malloc fails on adding a new card. --- src/rfid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rfid.c b/src/rfid.c index 2735632..7c32b3b 100644 --- a/src/rfid.c +++ b/src/rfid.c @@ -72,6 +72,8 @@ void rfid_add_card(const card_t *card) new_card_user = malloc(strlen(card->user) + 1); if (!new_card || !new_card_user) { printf_P(PSTR(OUT_OF_MEMORY_MSG "\n")); + free(new_card_user); + free(new_card); return; }