cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: segfault in hash.c

From: Jeff Pohlmeyer <yetanothergeek_at_yahoo.com>
Date: Sat, 13 Sep 2003 02:57:02 -0700 (PDT)

I think I see the problem:

When Curl_hash_add() finds a duplicate entry in the hostcache,
it frees the existing entry, and then assigns the new dns record
to the existing hostname. But it does not check to see if the
existing entry is in use by another easy handle before freeing it.

This patch seems to solve the problem, but I didn't check
to see if it creates a memory leak or not:

--- curl/lib/hostip.c Thu Sep 11 16:27:19 2003
+++ curl/lib/hostip.c Sat Sep 13 04:49:57 2003
@@ -364,9 +364,10 @@
 {
   struct Curl_dns_entry *p = (struct Curl_dns_entry *) freethis;
 
- Curl_freeaddrinfo(p->addr);
-
- free(p);
+ if ( !p->inuse ) {
+ Curl_freeaddrinfo(p->addr);
+ free(p);
+ }
 }
 
 /* --- resolve name or IP-number --- */

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-09-13