cURL

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[curl:bugs] #1362 Increment the initialized counter in curl_global_init_mem()

From: Daniel Stenberg <bagder_at_users.sf.net>
Date: Tue, 22 Apr 2014 21:08:47 +0000

- **status**: open-confirmed --> closed-fixed
- **Comment**:

Thanks, this fix has now been pushed to git!

---
** [bugs:#1362] Increment the initialized counter in curl_global_init_mem()**
**Status:** closed-fixed
**Labels:** curl_global_init_mem 
**Created:** Thu Apr 17, 2014 09:28 PM UTC by Tristan
**Last Updated:** Tue Apr 22, 2014 08:56 PM UTC
**Owner:** Daniel Stenberg
Hello,
I think there is an issue in easy.c, in the curl_global_init_mem() function
The initialized counter is not incremented if the libcurl is already initialized.
I'm currently doing two inits and two shutdowns, and here is the problem I met :
1) curl_global_init_mem(); // Actually initialize libcurl (initialized = 1)
2) curl_global_init_mem(); // Should do nothing (initialized stays to 1 instead of being incremented)
3) curl_global_cleanup(); // Actually cleanup libcurl because initialized = 1 
4) curl_global_cleanup();
After step 3 the variables that were created using the custom malloc are released using the default free, which raises an assert by libc on non-matching heap :
Invalid address specified to RtlValidateHeap
I could fix that by modifying easy.c the following way:
    @@ -300,8 +300,10 @@
         return CURLE_FAILED_INIT;
    
       /* Already initialized, don't do it again */
    -  if(initialized)
    +  if(initialized) {
    +    initialized++;
         return CURLE_OK;
    +  }
    
       /* Call the actual init function first */
       code = curl_global_init(flags);
However, maybe there is a better fix than duplicating the increment from curl_global_init()?
I'm using Libcurl 7.34.0, and checked quickly for a fix in 7.36.0, but I didn't find it.
---
Sent from sourceforge.net because curl-tracker@cool.haxx.se is subscribed to https://sourceforge.net/p/curl/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/curl/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
Received on 2014-04-22

These mail archives are generated by hypermail.

donate! Page updated March 21, 2014.
web site info

File upload with ASP.NET