diff options
author | Yang Tse <yangsita@gmail.com> | 2011-09-25 18:53:29 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2011-09-25 19:05:46 +0200 |
commit | 119f43360b60c903982104944145d9cd8b7ec054 (patch) | |
tree | 7cba5f3f98a946c0dca572eb22a2f48e98c5ee10 /lib/sendf.c | |
parent | e276802ff84d58aa2484f8292651dad4c50a5407 (diff) | |
download | curl-119f43360b60c903982104944145d9cd8b7ec054.tar.gz |
allow write callbacks to indicate OOM to libcurl
Allow (*curl_write_callback) write callbacks to return
CURL_WRITEFUNC_OUT_OF_MEMORY to properly indicate libcurl of OOM conditions
inside the callback itself.
Diffstat (limited to 'lib/sendf.c')
-rw-r--r-- | lib/sendf.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sendf.c b/lib/sendf.c index 847090be3..e9d5c3775 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -459,6 +459,11 @@ CURLcode Curl_client_write(struct connectdata *conn, wrote = len; } + if(CURL_WRITEFUNC_OUT_OF_MEMORY == wrote) { + failf(data, "Out of memory writing body"); + return CURLE_OUT_OF_MEMORY; + } + if(CURL_WRITEFUNC_PAUSE == wrote) return pausewrite(data, type, ptr, len); @@ -481,6 +486,12 @@ CURLcode Curl_client_write(struct connectdata *conn, regardless of the ftp transfer mode (ASCII/Image) */ wrote = writeit(ptr, 1, len, data->set.writeheader); + + if(CURL_WRITEFUNC_OUT_OF_MEMORY == wrote) { + failf(data, "Out of memory writing header"); + return CURLE_OUT_OF_MEMORY; + } + if(CURL_WRITEFUNC_PAUSE == wrote) /* here we pass in the HEADER bit only since if this was body as well then it was passed already and clearly that didn't trigger the pause, |