summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2008-11-12 01:02:49 +0000
committerJohn Christopher Anderson <jchris@apache.org>2008-11-12 01:02:49 +0000
commit41e60ecc969649e9c1deee5d293f2451e8238ac6 (patch)
treebb4312de59b9a4fb4535fd110b11588f39e05b55 /src/couchdb
parent9044fc0234ed65056f087a86c7c117922f2a2c75 (diff)
fix occasional curl segfault. thanks davisp
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@713234 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_js.c8
1 files changed, 5 insertions, 3 deletions
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);