Fix a memory leak when malloc fails on adding a new card.

This commit is contained in:
Arti Zirk 2016-12-21 01:42:08 +02:00
parent 3c69228743
commit 0f5a58fa50

View File

@ -72,6 +72,8 @@ void rfid_add_card(const card_t *card)
new_card_user = malloc(strlen(card->user) + 1); new_card_user = malloc(strlen(card->user) + 1);
if (!new_card || !new_card_user) { if (!new_card || !new_card_user) {
printf_P(PSTR(OUT_OF_MEMORY_MSG "\n")); printf_P(PSTR(OUT_OF_MEMORY_MSG "\n"));
free(new_card_user);
free(new_card);
return; return;
} }