]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core] fix leak in http request parser
authorMike Jerris <mike@signalwire.com>
Tue, 6 Oct 2020 15:26:42 +0000 (11:26 -0400)
committerAndrey Volk <andywolk@gmail.com>
Tue, 16 Mar 2021 21:55:08 +0000 (00:55 +0300)
src/switch_utils.c

index e4e26a6eef95337cccd6151453826c470b57aecd..5d6b8f2aaf89d29aefe0c6d63a236a218a185b05 100644 (file)
@@ -4176,11 +4176,12 @@ SWITCH_DECLARE(void) switch_http_parse_qs(switch_http_request_t *request, char *
        char *q;
        char *next;
        char *name, *val;
+       char *dup = NULL;
 
        if (qs) {
                q = qs;
        } else { /*parse our own qs, dup to avoid modify the original string */
-               q = strdup(request->qs);
+               dup = q = strdup(request->qs);
        }
 
        switch_assert(q);
@@ -4207,9 +4208,7 @@ SWITCH_DECLARE(void) switch_http_parse_qs(switch_http_request_t *request, char *
                q = next;
        } while (q);
 
-       if (!qs) {
-               switch_safe_free(q);
-       }
+       switch_safe_free(dup);
 }
 
 /* clean the uri to protect us from vulnerability attack */