get_url_spec_param(): Free memory of compiled pattern spec before bailing
authorJoshua Rogers <jrogers@opera.com>
Fri, 19 Nov 2021 16:32:23 +0000 (17:32 +0100)
committerFabian Keil <fk@fabiankeil.de>
Tue, 7 Dec 2021 14:06:06 +0000 (15:06 +0100)
OVE-20211201-0003. CVE-2021-44540.

cgiedit.c

index 3b8b12c..e73d5ee 100644 (file)
--- a/cgiedit.c
+++ b/cgiedit.c
@@ -1899,12 +1899,12 @@ static jb_err get_url_spec_param(struct client_state *csp,
    }
    err = create_pattern_spec(compiled, s);
    free(s);
+   free_pattern_spec(compiled);
    if (err)
    {
       free(param);
       return (err == JB_ERR_MEMORY) ? JB_ERR_MEMORY : JB_ERR_CGI_PARAMS;
    }
-   free_pattern_spec(compiled);
 
    if (param[strlen(param) - 1] == '\\')
    {
@@ -1935,12 +1935,12 @@ static jb_err get_url_spec_param(struct client_state *csp,
       }
       err = create_pattern_spec(compiled, s);
       free(s);
+      free_pattern_spec(compiled);
       if (err)
       {
          free(param);
          return (err == JB_ERR_MEMORY) ? JB_ERR_MEMORY : JB_ERR_CGI_PARAMS;
       }
-      free_pattern_spec(compiled);
    }
 
    *pvalue = param;