Fixed potential memory leak (bug 273)
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




photron/openwsman,vcrhonek/openwsman,Openwsman/openwsman,kolbma/openwsman,Openwsman/openwsman,vcrhonek/openwsman,photron/openwsman,Openwsman/openwsman,photron/openwsman,photron/openwsman,kolbma/openwsman,kolbma/openwsman,kkaempf/openwsman,kkaempf/openwsman,kkaempf/openwsman,Openwsman/openwsman,kkaempf/openwsman,photron/openwsman,vcrhonek/openwsman,Openwsman/openwsman,kolbma/openwsman,kolbma/openwsman,photron/openwsman,kkaempf/openwsman,kkaempf/openwsman,kolbma/openwsman,photron/openwsman,vcrhonek/openwsman,Openwsman/openwsman,vcrhonek/openwsman,Openwsman/openwsman,vcrhonek/openwsman,kolbma/openwsman,kkaempf/openwsman,vcrhonek/openwsman