Fix another memory leak on malloc fail

This commit is contained in:
Arti Zirk 2016-12-21 02:37:15 +02:00
parent 0f5a58fa50
commit 0c1783a47c

View File

@ -163,6 +163,10 @@ void cli_rfid_add(const char *const *argv)
card.uid_size = uid.size; card.uid_size = uid.size;
memcpy(&card.uid, &uid.uidByte, uid.size); memcpy(&card.uid, &uid.uidByte, uid.size);
char *user = malloc(strlen(argv[1]) + 1); char *user = malloc(strlen(argv[1]) + 1);
if(!user) {
printf_P(PSTR(OUT_OF_MEMORY_MSG "\n"));
return;
}
strcpy(user, argv[1]); strcpy(user, argv[1]);
card.user = user; card.user = user;
rfid_add_card(&card); rfid_add_card(&card);