Fix a memory leak when malloc fails on adding a new card.
This commit is contained in:
parent
3c69228743
commit
0f5a58fa50
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user