]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tftp: release filename if conn_get_remote_addr fails
authorx2018 <xkernel.wang@foxmail.com>
Sat, 8 Nov 2025 15:44:58 +0000 (23:44 +0800)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 9 Nov 2025 10:32:57 +0000 (11:32 +0100)
Closes #19409

lib/tftp.c

index ffea60f62190fad0ba9317a870c613997bb7970e..653654315147f771da03c48e470f9327f3931675 100644 (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)));