Changeset 3020
- Timestamp:
- 11/10/08 22:28:10 (2 months ago)
- Author:
- nashif
- Message:
Fixed potential memory leak (bug 273)
In file uri.c, method u_parse_query() mallocs memory for key and val
character pointers but this is never free'd in cases where string unify
operations fail, hash insertions fail or when there is already a
duplicate entry present in the hash.
The following is the proposed patch to fix the bug:
Index: src/lib/u/uri.c
===================================================================
--- src/lib/u/uri.c (revision 3016)
+++ src/lib/u/uri.c (working copy)
@@ -227,14 +227,19 @@
u_trim_quotes(val);
if (u_string_unify(key)
u_string_unify(val)) {
u_free(key);
+ u_free(val);
dbg("Could not unify query: %s", tok);
continue;
}
if (!hash_lookup(h, key)) {
if (!hash_alloc_insert(h, key, val)) {
+ u_free(key);
+ u_free(val);
warn("hash_alloc_insert failed");
}
} else {
+ u_free(key);
+ u_free(val);
warn("duplicate not added to hash");
}
}
--
Suresh Sundriyal
- Files:
- openwsman/trunk/src/lib/u/uri.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openwsman/trunk/src/lib/u/uri.c
r2779 r3020 228 228 if (u_string_unify(key) || u_string_unify(val)) { 229 229 u_free(key); 230 u_free(val); 230 231 dbg("Could not unify query: %s", tok); 231 232 continue; … … 233 234 if (!hash_lookup(h, key)) { 234 235 if (!hash_alloc_insert(h, key, val)) { 236 u_free(key); 237 u_free(val); 235 238 warn("hash_alloc_insert failed"); 236 239 } 237 240 } else { 241 u_free(key); 242 u_free(val); 238 243 warn("duplicate not added to hash"); 239 244 }
Download in other formats:
Powered by Trac 0.10.4
By Edgewall Software.Visit the Trac open source project at
http://trac.edgewall.com/
