From c9d78665a7e39f6416c92430ba695d2e47c7b878 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 22 Apr 2008 16:27:42 +0000 Subject: [PATCH] In parse_http_request(), remove a pointless temporary variable and free the buffer earlier. --- urlmatch.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/urlmatch.c b/urlmatch.c index 09db9295..30445d3f 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,4 @@ -const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.37 2008/04/17 14:53:29 fabiankeil Exp $"; +const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.38 2008/04/18 05:17:18 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $ @@ -33,6 +33,9 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.37 2008/04/17 14:53:29 fabianke * * Revisions : * $Log: urlmatch.c,v $ + * Revision 1.38 2008/04/18 05:17:18 fabiankeil + * Mark simplematch()'s parameters as immutable. + * * Revision 1.37 2008/04/17 14:53:29 fabiankeil * Move simplematch() into urlmatch.c as it's only * used to match (old-school) domain patterns. @@ -625,7 +628,6 @@ jb_err parse_http_request(const char *req, char *v[10]; /* XXX: Why 10? We should only need three. */ int n; jb_err err; - int is_connect = 0; memset(http, '\0', sizeof(*http)); @@ -658,11 +660,6 @@ jb_err parse_http_request(const char *req, return JB_ERR_PARSE; } - if (strcmpic(v[0], "CONNECT") == 0) - { - is_connect = 1; - } - err = parse_http_url(v[1], http, csp); if (err) { @@ -673,20 +670,20 @@ jb_err parse_http_request(const char *req, /* * Copy the details into the structure */ - http->ssl = is_connect; + http->ssl = !strcmpic(v[0], "CONNECT"); http->cmd = strdup(req); http->gpc = strdup(v[0]); http->ver = strdup(v[2]); + freez(buf); + if ( (http->cmd == NULL) || (http->gpc == NULL) || (http->ver == NULL) ) { - free(buf); return JB_ERR_MEMORY; } - free(buf); return JB_ERR_OK; } -- 2.39.2