cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Timeout & crash Issue

From: Joe Halpin <j.p.h_at_comcast.net>
Date: Sat, 20 Mar 2004 15:52:54 -0600

Gunn_Fergal_at_emc.com wrote:

> if (status == 0)
> {
> string out = outbuf.str();
> int index = out.find_last_of("</Packet>");
> xml_data = out.substr(0,index+1);
> }
> curl_slist_free_all(headers);
> curl_easy_cleanup(curl);
> }
> }

In addition to the other comments that have been made here, there's a
memory leak in this code. When you call ostrstream::str() it assumes the
caller has assumed responsibility for the buffer and it will not delete
it. You need to either delete [] the buffer, or give it back to the
ostrstream object with the streambuf freeze() function.

This is one reason why stringstreams are preferred (if your compiler has
them yet).

Joe
Received on 2004-03-20