aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-06-13 22:32:00 +0200
committerDaniel Stenberg <daniel@haxx.se>2011-06-13 22:32:00 +0200
commit0aedccc18a33a7785350d8d622ef273c727690cf (patch)
treeba4b8515fb0e38faea400c30eb66d69e418bd522 /tests/unit
parent85881f9f35832dbd4ef28940267f8fa30cbb867e (diff)
curl_formget: fix FILE * leak
Properly deal with the fact that the last fread() call most probably is a short read, and when using callbacks in fact all calls can be short reads. No longer consider a file read done until it returns a 0 from the read function. Reported by: Aaron Orenstein Bug: http://curl.haxx.se/mail/lib-2011-06/0048.html
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/unit1308.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unit/unit1308.c b/tests/unit/unit1308.c
index 6b2ab0da6..80e6c57b0 100644
--- a/tests/unit/unit1308.c
+++ b/tests/unit/unit1308.c
@@ -75,4 +75,21 @@ UNITTEST_START
curl_formfree(post);
+ /* start a new formpost with a file upload and formget */
+ post = last = NULL;
+
+ rc = curl_formadd(&post, &last,
+ CURLFORM_PTRNAME, "name of file field",
+ CURLFORM_FILE, "log/test-1308",
+ CURLFORM_FILENAME, "custom named file",
+ CURLFORM_END);
+
+ fail_unless(rc == 0, "curl_formadd returned error");
+
+ rc = curl_formget(post, &total_size, print_httppost_callback);
+ fail_unless(rc == 0, "curl_formget returned error");
+ fail_unless(total_size == 847, "curl_formget got wrong size back");
+
+ curl_formfree(post);
+
UNITTEST_STOP