]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool/var: free memory on OOM
authorDaniel Stenberg <daniel@haxx.se>
Wed, 2 Aug 2023 11:20:08 +0000 (13:20 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 2 Aug 2023 14:09:43 +0000 (16:09 +0200)
Coverity detected this memory leak in OOM situation

Follow-up to 2e160c9c652504e

Closes #11575

src/var.c

index 70e864cf605e6cc036582ec6339376cf053c0af5..88f2705f684620702665fb789c711a1679399eca 100644 (file)
--- a/src/var.c
+++ b/src/var.c
@@ -154,11 +154,11 @@ static ParameterError varfunc(struct GlobalConfig *global,
         }
 
         /* put it in the output */
-        if(curlx_dyn_add(out, enc)) {
+        if(curlx_dyn_add(out, enc))
           err = PARAM_NO_MEM;
-          break;
-        }
         curl_free(enc);
+        if(err)
+          break;
       }
     }
     else if(FUNCMATCH(f, FUNC_B64, FUNC_B64_LEN)) {