Memory leak in HTHash.

Torbjörn Carlsson <[email protected]>
Newsgroups gmane.comp.lib.libwww
Message-ID <[email protected]>
Hi.

I just found 2 memory leaks i HTHash. 
One in HTHashtable_removeObject and one in HTHashtable_walk.

See attached patch.

(Found by using the really nice Linux memory debugger valgrind, 
 http://developer.kde.org/~sewardj/ )

Regards
/Torbjörn

--
Torbjörn Carlsson                               Mobility Partner AB
email:  [email protected]    Box 1117, Kungsbron 21
phone:  +46 730 40 68 10                        111 81 Stockholm
HTHash.patch (text/plain, 610 B)
*** HTHash.c.orig	2003-05-13 09:30:25.000000000 +0200
--- HTHash.c	2003-05-13 09:11:26.000000000 +0200
***************
*** 117,122 ****
--- 117,124 ----
  	    while ((kn = (keynode *) HTList_nextObject(cur))) {
  		if(!strcmp(key,kn->key)) {
  		    HTList_removeObject(l,kn);
+ 		    HT_FREE(kn->key);
+ 		    HT_FREE(kn);
  		    me->count--;
  		    return YES;
  		}
***************
*** 186,191 ****
--- 188,195 ----
  		    nextkn = (keynode *)HTList_nextObject(cur);
  		    if (j < 0) {
  			HTList_removeObject(l, kn);
+ 		        HT_FREE(kn->key);
+ 			HT_FREE(kn);
  			me->count--;
  		    }
  		}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.