curl-library
Re: Known problems with simple formadd and curl_formfree?
Date: Sat, 19 Jan 2008 18:41:53 -0500
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
Received on 2008-01-20