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 /src/tool_cb_wrt.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 'src/tool_cb_wrt.c')
-rw-r--r-- | src/tool_cb_wrt.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 3a2cd791a..16edd7199 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -51,6 +51,10 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata) */ const size_t err_rc = (sz * nmemb) ? 0 : 1; + if(sz * nmemb >= CURL_WRITEFUNC_PAUSE) + /* CURL_WRITEFUNC_PAUSE limits input size */ + return CURL_WRITEFUNC_OUT_OF_MEMORY; + if(!out->stream) { out->bytes = 0; /* nothing written yet */ if(!out->filename) { |