Mailing Lists
|
cURL Mailing List Monthly Index Single Mail
curl-tracker Archives
[curl:bugs] #1241 curl_formadd leak
From: yayaigo <yayaigo_at_users.sf.net>
Date: Fri, 28 Feb 2014 16:09:26 +0000
LinkedIn
I'd like to add you to my professional network on LinkedIn.
- 敬錞潘
敬錞潘
Confirm that you know 敬錞潘:
-- You are receiving Invitation to Connect emails. Click to unsubscribe: http://www.linkedin.com/e/-ozowl2-hs7n59kx-6w/V3EL_D-as5IPgZkV7e-OgbkaNPISiSqrtUijIuda/goo/1241%40bugs%2Ecurl%2Ep%2Ere%2Esf%2Enet/20061/I6586441529_1/?hs=false&tok=2On8A-OHVpqm81 (c) 2012 LinkedIn Corporation. 2029 Stierlin Ct, Mountain View, CA 94043, USA. --- ** [bugs:#1241] curl_formadd leak** **Status:** closed-invalid **Labels:** memory leak **Created:** Thu Jun 06, 2013 09:54 AM UTC by yayaigo **Last Updated:** Fri Jun 21, 2013 01:43 PM UTC **Owner:** Daniel Stenberg I use libcurl multipart upload file, and I get leak info in the XCode instruments. curl_formadd seem to have leak. The leak info is below: Bytes Used # Leaks Symbol Name 656 Bytes 100.0% 17 thread_start 656 Bytes 100.0% 17 _pthread_start 656 Bytes 100.0% 17 _ZN7cocos2d9extensionL13networkThreadEPv 656 Bytes 100.0% 17 cocos2d::extension::processPostMultipartTask(cocos2d::extension::CCHttpRequest*, unsigned long (*)(void*, unsigned long, unsigned long, void*), void*, int*) 656 Bytes 100.0% 17 curl_formadd 384 Bytes 58.5% 6 calloc 144 Bytes 21.9% 3 strdup 144 Bytes 21.9% 3 malloc 128 Bytes 19.5% 8 memdup My code is below: CURLcode code = CURL_LAST; CURL *curl = curl_easy_init(); do { if (!configureCURL(curl)) { break; } /* handle custom header data */ /* create curl linked list */ struct curl_slist *cHeaders=NULL; /* get custom header data (if set) */ std::vector<std::string> headers=request->getHeaders(); if(!headers.empty()) { for(std::vector<std::string>::iterator it=headers.begin();it!=headers.end();it++) { /* append custom headers one by one */ cHeaders=curl_slist_append(cHeaders,it->c_str()); } /* set custom headers for curl */ code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, cHeaders); if (code != CURLE_OK) { break; } } /* <form enctype="multipart/form-data" method="POST" action="http://xxx.xxx.xxx.xxx/xxxxx/public/member/upload" accept-charset="UTF-8"> <input type="file" name="uploadfile"> <input type="text" name="u_id" value="" id="u_id"> <input type="text" name="cali" value="" id="cali"> <input type="submit" value="Upload"> </form> */ struct curl_httppost *formpost = 0; struct curl_httppost *lastptr = 0; map<string,string>::iterator it = formData.begin(); for(;it != formData.end(); it++) { curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, (*it).first.c_str(), CURLFORM_COPYCONTENTS, (*it).second.c_str(), CURLFORM_END); } curl_formadd(&formpost, &lastptr, CURLFORM_PTRNAME, "uploadfile", CURLFORM_FILE, postMultipartFilePath, CURLFORM_END); code = curl_easy_setopt(curl, CURLOPT_URL, request->getUrl()); if (code != CURLE_OK) { break; } curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); if (code != CURLE_OK) { break; } code = curl_easy_perform(curl); if (code != CURLE_OK) { break; } curl_formfree(formpost); //curl_formfree(lastptr);//need use that remove leak? it will crash /* free the linked list for header data */ curl_slist_free_all(cHeaders); code = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, responseCode); if (code != CURLE_OK || *responseCode != 200) { code = CURLE_HTTP_RETURNED_ERROR; } } while (0); if (curl) { curl_easy_cleanup(curl); } So what do I miss something to do? Thanks. Regards. --- Sent from sourceforge.net because curl-tracker@cool.haxx.se is subscribed to http://sourceforge.net/p/curl/bugs/ To unsubscribe from further messages, a project admin can change settings at http://sourceforge.net/p/curl/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.Received on 2014-02-28 These mail archives are generated by hypermail. |
Page updated December 29, 2013.
web site info