cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: problem when using curlopts_writefunction

From: Gisle Vanem <gvanem_at_yahoo.no>
Date: Thu, 9 Jan 2014 20:15:09 +0100

"Joshua Kordani" <jkordani_at_lsa2.com> wrote:

> even if I assume I've been given any data, attempting to access memory
> at ptr fails. gdb has this to say
> rtsp::RtspClient::sdp_parse (this=0x1b0000001c03, ptr=0x1 <Address 0x1
> out of bounds>, size=2392498086155112, nmemb=140735181538536,

How did you manage to accept your C++-compiler to use a class-member as
a libcurl callback? Think about it. In <curl/curl.h>, the write-callback MUST
match this prototype:

  typedef size_t (*curl_write_callback)(char *buffer,
                                        size_t size,
                                        size_t nitems,
                                        void *outstream);

But your C++ callback seems to have a prototype (seen from libcurl) like
this:
  size_t rtsp::RtspClient::sdp_parse (this *,char *buffer,
                                      size_t size,
                                      size_t nitems,
                                      void *outstream);

This will crash.

You can either use a 'static RtspClient::sdp_parse' function or use CURLOPT_WRITEDATA
to set a pointer to the class instance you're working with.

--gv

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-09