http: don't crash on URI parse failure
authorStefan Becker <chemobejk@gmail.com>
Tue, 9 Jul 2013 07:00:58 +0000 (9 10:00 +0300)
committerStefan Becker <chemobejk@gmail.com>
Sat, 13 Jul 2013 12:55:50 +0000 (13 15:55 +0300)
sipe_http_parsed_uri_free can now be called with NULL pointer.

(cherry picked from commit 8d225558c3c2d60c6706a03dcd03b851da8e85ef)

src/core/sipe-http-request.h
src/core/sipe-http.c

index 493c078..9af42d7 100644 (file)
@@ -56,7 +56,7 @@ struct sipe_http_parsed_uri *sipe_http_parse_uri(const gchar *uri);
 /**
  * Free parsed URI data structure
  *
- * @param pointer to parsed URI.
+ * @param pointer to parsed URI (may be @c NULL)
  */
 void sipe_http_parsed_uri_free(struct sipe_http_parsed_uri *parsed_uri);
 
index 0482095..16913db 100644 (file)
 
 void sipe_http_parsed_uri_free(struct sipe_http_parsed_uri *parsed_uri)
 {
-       g_free(parsed_uri->host);
-       g_free(parsed_uri->path);
-       g_free(parsed_uri);
+       if (parsed_uri) {
+               g_free(parsed_uri->host);
+               g_free(parsed_uri->path);
+               g_free(parsed_uri);
+       }
 }
 
 struct sipe_http_parsed_uri *sipe_http_parse_uri(const gchar *uri)