Fix realloc mistake: ptr nulled but not freed upon failure

This commit is contained in:
Philippe Teuwen 2019-03-24 22:09:25 +01:00
commit 19588b045f

View file

@ -260,9 +260,12 @@ int CmdFlashMemLoad(const char *Cmd) {
break; break;
} }
data = realloc(data, datalen); uint8_t *newdata = realloc(data, datalen);
if (!data) { if (newdata == NULL) {
free(data);
return 1; return 1;
} else {
data = newdata;
} }
//Send to device //Send to device