cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Known problems with simple formadd and curl_formfree?

From: Max L. Eidswick <max_at_eidswick.com>
Date: Sat, 19 Jan 2008 18:23:16 -0700

THANKS!

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Lars Nilsson
Sent: Saturday, January 19, 2008 4:42 PM
To: libcurl development
Subject: Re: Known problems with simple formadd and curl_formfree?

On Jan 19, 2008 6:24 PM, Max L. Eidswick <max_at_eidswick.com> wrote:
> OK, one of our developers is sure this is not in his source :-). We have put together a small test case which follows. It is
> probably a very simple misinterpretation of the docs. This source runs fine with the formfree call commented out and crashes in
the
> second or third iteration if not.
...
> struct curl_httppost *formPostPing = NULL ; // for libcurl curl_formadd
> struct curl_httppost *lastPtr = NULL ; // for libcurl curl_formadd
...
> curl_formadd ( // add field/value for test
> &formPostPing, // the form to add to
> &lastPtr, // managed by formadd
> CURLFORM_COPYNAME, "clguid", // client guid for test
> // set the value of "filename" to src
> CURLFORM_COPYCONTENTS, // client guid value
> "{1234-12345678-1234-123456789012}", // for testing
> CURLFORM_END
> ) ; // per libcurl spec
...
> // *************************************************************
> // curl_formfree ( formPostPing ) ; // free the form
> // *************************************************************
...

Have you tried setting formPostPing and lastPtr to NULL before each
iteration? curl_formfree won't modify the pointer values, only free
the allocated storage. So on the second iteration, your first
curl_formadd would use an invalid pointer.

Lars Nilsson

Hi, Lars -- simple and perfect. We will not waste so much time messing with simple issues in the future. Thanks, very much. It is
running perfectly, so we can continue on to the next step.

Thanks, again, for taking the time to look at this problem.

Max
Received on 2008-01-20