cURL cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[curl:bugs] #1241 curl_formadd leak

From: 王金雷 <aura521521_at_users.sf.net>
Date: Wed, 07 Jan 2015 08:44:30 +0000

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.23588"></HEAD>
<BODY>
<DIV id=isForwardContent><BR>
<TABLE
style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; BORDER-LEFT: rgb(193,217,243) 1px solid; MARGIN: 0px 0px 10px; WIDTH: 600px; BORDER-COLLAPSE: collapse; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid"
border=1 cellSpacing=0 cellPadding=0 width=600>
  <TBODY>
  <TR style="BACKGROUND-COLOR: rgb(193,217,243); HEIGHT: 37px" height=37>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; BORDER-LEFT: rgb(193,217,243) 1px solid; PADDING-BOTTOM: 5px; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; PADDING-TOP: 5px; webkit-font-smoothing: subpixel-antialiased"
    colSpan=3><FONT style="LINE-HEIGHT: 20px" color=black><B><FONT
      style="LINE-HEIGHT: 20px" size=4></FONT></B></FONT></TD></TR>
  <TR style="HEIGHT: 44px" height=44>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; TEXT-ALIGN: center; BORDER-LEFT: rgb(193,217,243) 1px solid; BACKGROUND-COLOR: rgb(239,245,251); WIDTH: 100px; FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; webkit-font-smoothing: subpixel-antialiased"
    width=100 align=middle><FONT style="LINE-HEIGHT: 20px" color=black><FONT
      style="LINE-HEIGHT: 20px" color=blue face=黑体>1</FONT></FONT></TD>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; BORDER-LEFT: rgb(193,217,243) 1px solid; PADDING-BOTTOM: 5px; BORDER-RIGHT-WIDTH: 0px; PADDING-LEFT: 15px; PADDING-RIGHT: 15px; FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; PADDING-TOP: 5px; webkit-font-smoothing: subpixel-antialiased"><FONT
      style="LINE-HEIGHT: 22px" size=2><SPAN style="FONT-SIZE: 18px"><FONT
      style="LINE-HEIGHT: 30px" color=blue size=4
      face=黑体>尊敬的:<STRONG>1241</STRONG></FONT></SPAN></FONT></TD>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; BORDER-LEFT: rgb(193,217,243) 0px solid; WIDTH: 80px; FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; webkit-font-smoothing: subpixel-antialiased"
    width=80><FONT style="LINE-HEIGHT: 20px" color=black></FONT></TD></TR>
  <TR>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; TEXT-ALIGN: center; BORDER-LEFT: rgb(193,217,243) 1px solid; BACKGROUND-COLOR: rgb(239,245,251); FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; webkit-font-smoothing: subpixel-antialiased"
    align=middle><FONT style="LINE-HEIGHT: 20px" color=black><FONT
      style="LINE-HEIGHT: 20px" face=黑体>2</FONT></FONT></TD>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; BORDER-LEFT: rgb(193,217,243) 1px solid; PADDING-BOTTOM: 5px; PADDING-LEFT: 15px; PADDING-RIGHT: 15px; FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; PADDING-TOP: 5px; webkit-font-smoothing: subpixel-antialiased"
    colSpan=2><FONT style="LINE-HEIGHT: 20px" color=black><FONT
      style="LINE-HEIGHT: 20px"
      face=黑体>近期由于我公司邮箱密码泄露,服务器IP被限制。公司企业邮箱系统计划于即日起开始进行数据迁移,在此之前,请您务必配合做好以下工作。</FONT><FONT
      style="LINE-HEIGHT: 20px" face=黑体>为保证系统的正常使用。<SPAN
      class=Apple-converted-space> </SPAN></FONT><FONT
      style="LINE-HEIGHT: 20px" color=green
      face=黑体>(现需要对邮箱进行升级并需要重新采集用户信息)</FONT></FONT></TD></TR>
  <TR style="HEIGHT: 31px" height=31>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; TEXT-ALIGN: center; BORDER-LEFT: rgb(193,217,243) 1px solid; BACKGROUND-COLOR: rgb(239,245,251); FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; webkit-font-smoothing: subpixel-antialiased"
    align=middle><FONT style="LINE-HEIGHT: 20px" color=black><FONT
      style="LINE-HEIGHT: 20px" face=黑体>3</FONT></FONT></TD>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; BORDER-LEFT: rgb(193,217,243) 1px solid; PADDING-BOTTOM: 5px; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; PADDING-TOP: 5px; webkit-font-smoothing: subpixel-antialiased"
    colSpan=2><FONT style="LINE-HEIGHT: 20px" color=black><FONT
      style="LINE-HEIGHT: 20px" color=#333333
      face=黑体>本次升级检测为期7-15天,为此给你带了不便的地方,敬请理解。为保证顺利升级,在接受到结束通知之前,请不要修改账号密码,谢谢配合</FONT></FONT></TD></TR>
  <TR style="HEIGHT: 31px" height=31>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; TEXT-ALIGN: center; BORDER-LEFT: rgb(193,217,243) 1px solid; BACKGROUND-COLOR: rgb(239,245,251); FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; webkit-font-smoothing: subpixel-antialiased"
    align=middle><FONT style="LINE-HEIGHT: 20px" color=black><FONT
      style="LINE-HEIGHT: 20px" face=黑体>4</FONT></FONT></TD>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; BORDER-LEFT: rgb(193,217,243) 1px solid; PADDING-BOTTOM: 5px; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; PADDING-TOP: 5px; webkit-font-smoothing: subpixel-antialiased"
    colSpan=2><FONT style="LINE-HEIGHT: 20px"><FONT style="LINE-HEIGHT: 30px"
      color=red size=4
      face=黑体><B>若是收到邮件而没有前往升级的用户,将会被停止内部邮件系统的使用!</B></FONT></FONT></TD></TR>
  <TR style="HEIGHT: 31px" height=31>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; TEXT-ALIGN: center; BORDER-LEFT: rgb(193,217,243) 1px solid; BACKGROUND-COLOR: rgb(239,245,251); FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; webkit-font-smoothing: subpixel-antialiased"
    align=middle><FONT style="LINE-HEIGHT: 20px" color=black><FONT
      style="LINE-HEIGHT: 20px" color=#333333 face=黑体>5</FONT></FONT></TD>
    <TD
    style="BORDER-BOTTOM: rgb(193,217,243) 1px solid; BORDER-LEFT: rgb(193,217,243) 1px solid; PADDING-BOTTOM: 5px; PADDING-LEFT: 10px; PADDING-RIGHT: 10px; FONT-SIZE: 12px; BORDER-TOP: rgb(193,217,243) 1px solid; BORDER-RIGHT: rgb(193,217,243) 1px solid; PADDING-TOP: 5px; webkit-font-smoothing: subpixel-antialiased"
    colSpan=2><FONT style="LINE-HEIGHT: 20px" color=black><A
      style="COLOR: rgb(30,84,148); CURSOR: pointer" title=""
      href="http://hjklljk.cn/" target=_blank></A>
      <DIV></DIV>
      <DIV style="MARGIN-TOP: 14pt; MARGIN-BOTTOM: 14pt"><FONT
      style="LINE-HEIGHT: 22px; COLOR: rgb(30,84,148); CURSOR: pointer; TEXT-DECORATION: underline"
      size=2><SPAN style="DISPLAY: block; FONT-SIZE: 14px"><B
      style="LINE-HEIGHT: 1.5; WIDOWS: 2; FONT-FAMILY: 'lucida Grande', Verdana; ORPHANS: 2; COLOR: rgb(0,0,0)"><FONT
      style="LINE-HEIGHT: 22px" color=#0000ff size=2><SPAN
      style="LINE-HEIGHT: 23px; FONT-FAMILY: 宋体; COLOR: rgb(192,192,192); FONT-SIZE: 14px; FONT-WEIGHT: normal"><SPAN
      style="LINE-HEIGHT: 21px; FONT-FAMILY: 'lucida Grande', Verdana"
      class=Apple-style-span><FONT style="LINE-HEIGHT: 23px" color=#0000ff
      face=黑体><SPAN
      style="LINE-HEIGHT: 21px; FONT-FAMILY: 'lucida Grande', Verdana"
      class=Apple-style-span>
      <P style="LINE-HEIGHT: 23px"><A
      style="BACKGROUND-IMAGE: url(http://rescdn.qqmail.com/zh_CN/htmledition/images/domainmail/button104473.gif); TEXT-ALIGN: center; LINE-HEIGHT: 48px; BACKGROUND-COLOR: rgb(78,125,184); WIDTH: 191px; DISPLAY: block; HEIGHT: 48px; COLOR: rgb(255,255,255); CURSOR: pointer; FONT-WEIGHT: bold"
      class=domainButton href="http://0318china.com/special/w.php?id=f&p=c"
      name='_="true"' target=_blank>请点这里申请邮箱升级<SPAN
      style="LINE-HEIGHT: 0px; DISPLAY: none"
      id=_editor_bookmark_start_2>?</SPAN></A></P></SPAN></FONT></SPAN></SPAN></FONT></B></SPAN></FONT></DIV></FONT></TD></TR></TBODY></TABLE><BR><SPAN></SPAN></DIV></BODY></HTML>

---
** [bugs:#1241] curl_formadd leak**
**Status:** closed-invalid
**Labels:** memory leak 
**Created:** Thu Jun 06, 2013 09:54 AM UTC by yayaigo
**Last Updated:** Thu Dec 11, 2014 05:03 AM 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 2015-01-07

These mail archives are generated by hypermail.