Fix memory leaks

Free buf in the case of an error. Found via cppcheck.
This commit is contained in:
Yegor Yefremov 2021-12-24 10:14:16 +01:00
parent 3d39f3f232
commit d14bb02dca
2 changed files with 2 additions and 0 deletions

View File

@ -430,6 +430,7 @@ int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
if (serial_send(&pgm->fd, buf, len + 4) != 0) { if (serial_send(&pgm->fd, buf, len + 4) != 0) {
avrdude_message(MSG_INFO, "%s: jtag3_send(): failed to send command to serial port\n", avrdude_message(MSG_INFO, "%s: jtag3_send(): failed to send command to serial port\n",
progname); progname);
free(buf);
return -1; return -1;
} }

View File

@ -214,6 +214,7 @@ static int jtagmkI_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
if (serial_send(&pgm->fd, buf, len + 2) != 0) { if (serial_send(&pgm->fd, buf, len + 2) != 0) {
avrdude_message(MSG_INFO, "%s: jtagmkI_send(): failed to send command to serial port\n", avrdude_message(MSG_INFO, "%s: jtagmkI_send(): failed to send command to serial port\n",
progname); progname);
free(buf);
return -1; return -1;
} }