cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curlpp mailing list Archives

[cURLpp] Bug in HTTP Forms

From: Piotr Niemcunowicz <piotr.niemcunowicz_at_gmail.com>
Date: Tue, 05 Feb 2008 22:41:38 +0100

Hello everyone,

First of all: I`m new to this list, so hello again :)

There is a serious bug when using cURLpp::Options::HttpPost(const Forms
&posts) for sending POST forms.

Behavior: application crashes
How to reproduce: use the code from example19 to POST few times, usually
twice is enough (see attached test case)
Fix: add missing initialization list in constructor:

--- Form.cpp 2008-02-05 21:45:23.000000000 +0100
+++ Form.cpp 2007-08-28 01:35:16.000000000 +0200
@@ -26,8 +26,6 @@

cURLpp::HttpPost::HttpPost(const Forms &posts)
+ : mFirst(NULL)
+ , mLast(NULL)
{
  cURLpp::FormPart *form;
  Forms::const_iterator pos;

Regarding example19: there should be a code to dispose pointers from
std::list<cURLpp::FormPart *> formParts.
Or maybe should the cURLpp take the ownership of pointers and free them
instead of cloning and leaving this to the library user?

--
Best regards
Piotr Niemcunowicz

#include <stdlib.h>
#include <errno.h>

#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <curlpp/Exception.hpp>

void perform(const char* url) {
    cURLpp::Easy request;

    request.setOpt(new cURLpp::Options::Url(url));
    request.setOpt(new cURLpp::Options::Verbose(true));

    std::list<cURLpp::FormPart *> formParts;
    formParts.push_back(new cURLpp::FormParts::Content("name1", "value1"));
    formParts.push_back(new cURLpp::FormParts::Content("name2", "value2"));

    request.setOpt(new cURLpp::Options::HttpPost(formParts));

    request.perform();
}

int main(int argc, char *argv[])
{
  char *url = "http://localhost/";

  try {
    cURLpp::Cleanup cleaner;
    perform(url);
    perform(url); // it should crash inside
    perform(url);
    perform(url);
  }
  catch ( cURLpp::LogicError & e ) {
    std::cout << e.what() << std::endl;
  }
  catch ( cURLpp::RuntimeError & e ) {
    std::cout << e.what() << std::endl;
  }

  return EXIT_SUCCESS;
}

_______________________________________________
cURLpp mailing list
cURLpp_at_rrette.com
http://www.rrette.com/mailman/listinfo/curlpp
Received on 2008-02-05

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET