From 41e60ecc969649e9c1deee5d293f2451e8238ac6 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Wed, 12 Nov 2008 01:02:49 +0000 Subject: fix occasional curl segfault. thanks davisp git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@713234 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_js.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/couchdb/couch_js.c b/src/couchdb/couch_js.c index 21faac1c..a23eb5c8 100644 --- a/src/couchdb/couch_js.c +++ b/src/couchdb/couch_js.c @@ -786,7 +786,7 @@ PostHttp(JSContext *context, JSObject *obj, uintN argc, jsval *argv, jsval *rval curl_easy_setopt(handle,CURLOPT_HEADERFUNCTION,curl_write); curl_easy_setopt(handle,CURLOPT_WRITEHEADER,b); curl_easy_setopt(handle,CURLOPT_URL,url); // url - curl_easy_setopt(handle,CURLOPT_HTTPPOST,1); // Set Op. to post + curl_easy_setopt(handle,CURLOPT_POST,1); // Set Op. to post curl_easy_setopt(handle,CURLOPT_NOPROGRESS,1); // No Progress Meter curl_easy_setopt(handle,CURLOPT_IPRESOLVE,CURL_IPRESOLVE_V4); // only ipv4 @@ -797,8 +797,8 @@ PostHttp(JSContext *context, JSObject *obj, uintN argc, jsval *argv, jsval *rval return JS_FALSE; } - curl_easy_setopt(handle,CURLOPT_COPYPOSTFIELDS,body); // Curl wants '\0' terminated, we oblige - free(body); + curl_easy_setopt(handle,CURLOPT_POSTFIELDSIZE,strlen(body)); + curl_easy_setopt(handle,CURLOPT_POSTFIELDS,body); // Curl wants '\0' terminated, we oblige struct curl_slist *slist = generateCurlHeaders(context,argv+2); // Initialize Headers if(slist != NULL) { @@ -809,12 +809,14 @@ PostHttp(JSContext *context, JSObject *obj, uintN argc, jsval *argv, jsval *rval if((exitcode = curl_easy_perform(handle)) != 0) { // Perform curl_slist_free_all(slist); + free(body); free(url); free_Buffer(b); curl_easy_cleanup(handle); return JS_FALSE; } + free(body); free(url); curl_slist_free_all(slist); -- cgit v1.2.3