On 06/04/2020 18:02, Tomalak Geret'kal wrote: > It is more likely that curl_east_setopt is expecting the > C-string you give it to live for the duration of the handle > (as it does with the request headers). > > Thus, switching to a "buffer" may not be enough (the pointer > you were extracting from your std::string points to a > "buffer" too!) - you still have undefined behaviour if you > cannot guarantee the lifetime of the char array. > > There are still not enough details to tell whether that's > the case for you. But be warned that this is about lifetime, > not about "buffers". > > Cheers
Adding to the above, I quote the curl_setopt_easy documentation: > Strings passed to libcurl as 'char *' arguments, are copied by the library; thus the string storage associated to the pointer argument may be overwritten after curl_easy_setopt returns. The only exception to this rule is really CURLOPT_POSTFIELDS, but the alternative that copies the string CURLOPT_COPYPOSTFIELDS has some usage characteristics you need to read up on. > > The order in which the options are set does not matter. > > Before version 7.17.0, strings were not copied. Instead the user was forced keep them available until libcurl no longer needed them. So, if you're using version 7.17.0 or later, there is still a mystery about your problem. If you're using an earlier version, that's the explanation. Though you should upgrade. Cheers ------------------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html