tftp: release filename if conn_get_remote_addr fails

Closes #19409
This commit is contained in:
x2018 2025-11-08 23:44:58 +08:00 committed by Daniel Stenberg
parent 239c389836
commit 59584399a5
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -479,6 +479,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
state->blksize,
"%s%c%s%c", filename, '\0', mode, '\0');
sbytes = 4 + strlen(filename) + strlen(mode);
free(filename);
/* optional addition of TFTP options */
if(!data->set.tftp_no_options) {
@ -517,7 +518,6 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
if(result != CURLE_OK) {
failf(data, "TFTP buffer too small for options");
free(filename);
return CURLE_TFTP_ILLEGAL;
}
}
@ -537,7 +537,6 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
(SEND_TYPE_ARG3)sbytes, 0,
CURL_SENDTO_ARG5(&remote_addr->curl_sa_addr),
(curl_socklen_t)remote_addr->addrlen);
free(filename);
if(senddata != (ssize_t)sbytes) {
char buffer[STRERROR_LEN];
failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));