cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: crash at end of program problem - c++

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Sat, 17 Oct 2009 17:32:40 +0200

On Saturday 17 of October 2009 17:06:22 will griffiths wrote:
> #include <string>
> #include <iostream>
> #include <map>
> #include <sstream>
> #include <fstream>
> #include <regex>
> #include "curl/curl.h"
>
> using namespace std;
>
> typedef map<int, string> MultiQ;
> MultiQ multiq;

A vector seems to be better choice for int-to-string mapping...

> typedef map<string, string> MultiU;
> MultiU multiu;
> MultiU buffer;
>
>
>
> static int getpage(char *data, size_t size, size_t nmemb, std::string
> *buffer) {
> int result = 0;
> if (buffer != NULL) {
>     buffer->append(data, size * nmemb);
>     result = size * nmemb;
> }
> return result;
> }
>
>
>
> static void geturl(CURLM *mh, int i, string urlstring)
> {
> cout << "geturl" << i << "\n";
> char *urlbuf = new char[urlstring.length()];

off-by-one error here ^^^

Try to start with simplifying the code. It's too complex to be read by you as
the author. How can be it read by others then?

Kamil
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-10-17