Merge pull request #779 from yegorich/memleaks

Fix memory leaks

In jtag3_send() and jtagmkI_send(), free the buffer when returning an error.
This commit is contained in:
Jörg Wunsch 2021-12-26 00:44:33 +01:00 committed by GitHub
commit c60c5c4b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
} }