Looking at src/lib/u/uri.c (talk about excessive use of macros!!), there
are two places that I can identify potential memory leaks.
In function u_uri_parse(), after uri_string is strdup'ed, in case of an
error, the dbg_err_if macro, inside 'if(question)' conditional, makes a
jump to err, where the function returns without free'ing uri_string.
Second, in u_parse_query, in case of an error with this call:
dbg_err_if(val == NULL);
the control jumps to err, however *key points to a strdup'ed memory
location that needs to be free'd before returning.
I need to make the initial pointers NULL, since previous calls to
dbg_err_if, might cause those pointers with garbage to be passed to
u_free().
The attached patch fixes these leaks.
--
Suresh
Index: src/lib/u/uri.c
===================================================================
--- src/lib/u/uri.c (revision 3254)
+++ src/lib/u/uri.c (working copy)
@@ -107,7 +107,7 @@
{
const char *p, *p0;
const char *end, *question;
- char *uri_string;
+ char *uri_string=NULL;
int i;
u_uri_t *uri;
@@ -161,6 +161,7 @@
u_free(uri_string);
return 0;
err:
+ u_free(uri_string);
u_uri_free(uri);
return ~0;
}
@@ -202,7 +203,7 @@
hash_t *u_parse_query(const char *query)
{
char *pp, *tok, *src, *q = NULL;
- char *key, *val;
+ char *key=NULL, *val=NULL;
hash_t *h = NULL;
dbg_err_if(query == NULL);
@@ -247,6 +248,7 @@
return h;
err:
u_free(q);
+ u_free(key);
return NULL;
}
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.
http://p.sf.net/sfu/bobj-july_______________________________________________
Openwsman-devel mailing list
Openwsman-devel@...
https://lists.sourceforge.net/lists/listinfo/openwsman-devel