From ec73fd89ed5b526548e61527037e1603234333a0 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 5 Oct 2011 16:41:04 +0200 Subject: curl tool: OOM handling fixes --- src/tool_getparam.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/tool_getparam.c') diff --git a/src/tool_getparam.c b/src/tool_getparam.c index ae2970fb7..1c92e053a 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -936,7 +936,8 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ } else { GetStr(&postdata, p); - size = strlen(postdata); + if(postdata) + size = strlen(postdata); } if(!postdata) { @@ -1019,8 +1020,12 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ } #ifdef CURL_DOES_CONVERSIONS - if(subletter != 'b') { /* NOT forced binary, convert to ASCII */ - convert_to_network(postdata, strlen(postdata)); + if(subletter != 'b') { + /* NOT forced binary, convert to ASCII */ + if(convert_to_network(postdata, strlen(postdata))) { + Curl_safefree(postdata); + return PARAM_NO_MEM; + } } #endif @@ -1032,6 +1037,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ curl_off_t newlen = oldlen + size + 2; config->postfields = malloc((size_t)newlen); if(!config->postfields) { + Curl_safefree(oldpost); Curl_safefree(postdata); return PARAM_NO_MEM; } @@ -1053,8 +1059,10 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ We can't set the request type here, as this data might be used in a simple GET if -G is used. Already or soon. - if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq)) - return PARAM_BAD_USE; + if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq)) { + Curl_safefree(postdata); + return PARAM_BAD_USE; + } */ break; case 'D': -- cgit v1.2.1