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
[email protected]
http://www.rrette.com/mailman/listinfo/curlpp

Reply via email to