]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http_chunks: narrow variable scope for 'trlen'
authorDaniel Stenberg <daniel@haxx.se>
Mon, 12 May 2025 07:07:50 +0000 (09:07 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 12 May 2025 09:02:00 +0000 (11:02 +0200)
CodeSonar found a case where it would be assigned but never used and
narrowing the scope makes sense anyway.

Closes #17316

lib/http_chunks.c

index 9d734c5354e714b6cb4712c75571bfa45351f65f..63e477c48a68b3b0cd21ac9948d07c692a18cd78 100644 (file)
@@ -256,7 +256,6 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data,
            there was no trailer and we move on */
 
         if(tr) {
-          size_t trlen;
           result = curlx_dyn_addn(&ch->trailer, STRCONST("\x0d\x0a"));
           if(result) {
             ch->state = CHUNK_FAILED;
@@ -264,8 +263,8 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data,
             return result;
           }
           tr = curlx_dyn_ptr(&ch->trailer);
-          trlen = curlx_dyn_len(&ch->trailer);
           if(!data->set.http_te_skip) {
+            size_t trlen = curlx_dyn_len(&ch->trailer);
             if(cw_next)
               result = Curl_cwriter_write(data, cw_next,
                                           CLIENTWRITE_HEADER|