fix a (minor) memory leak in case of error

CID 21 in the coverity.com scan
This commit is contained in:
Daniel Stenberg 2007-03-31 21:15:37 +00:00
parent c1f117700a
commit dc2ea33e32

View File

@ -2052,8 +2052,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
char *oldpost=config->postfields;
size_t newlen = strlen(oldpost) + strlen(postdata) + 2;
config->postfields=malloc(newlen);
if(!config->postfields)
if(!config->postfields) {
free(postdata);
return PARAM_NO_MEM;
}
/* use ASCII value 0x26 for '&' to accommodate non-ASCII platforms */
snprintf(config->postfields, newlen, "%s\x26%s", oldpost, postdata);
free(oldpost);