struct curl_httppost *post)
{
CURLcode ret = CURLE_OK;
+ char *escaped = NULL;
bool skip = FALSE;
ret = curl_easy_setopt(curl, tag, post);
for(pp=p; pp; pp=pp->more) {
/* May be several files uploaded for one name;
* these are linked through the 'more' pointer */
- char *e;
- e = c_escape(pp->contents);
- if(!e) {
+ Curl_safefree(escaped);
+ escaped = c_escape(pp->contents);
+ if(!escaped) {
ret = CURLE_OUT_OF_MEMORY;
goto nomem;
}
if(pp->flags & HTTPPOST_FILENAME) {
/* file upload as for -F @filename */
- DATA1(" CURLFORM_FILE, \"%s\",", e);
+ DATA1(" CURLFORM_FILE, \"%s\",", escaped);
}
else if(pp->flags & HTTPPOST_READFILE) {
/* content from file as for -F <filename */
- DATA1(" CURLFORM_FILECONTENT, \"%s\",", e);
+ DATA1(" CURLFORM_FILECONTENT, \"%s\",", escaped);
}
else
- DATA1(" CURLFORM_COPYCONTENTS, \"%s\",", e);
- free(e);
+ DATA1(" CURLFORM_COPYCONTENTS, \"%s\",", escaped);
if(pp->showfilename) {
- e = c_escape(pp->showfilename);
- if(!e) {
+ Curl_safefree(escaped);
+ escaped = c_escape(pp->showfilename);
+ if(!escaped) {
ret = CURLE_OUT_OF_MEMORY;
goto nomem;
}
- DATA1(" CURLFORM_FILENAME, \"%s\",", e);
- free(e);
+ DATA1(" CURLFORM_FILENAME, \"%s\",", escaped);
}
if(pp->contenttype) {
- e = c_escape(pp->contenttype);
- if(!e) {
+ Curl_safefree(escaped);
+ escaped = c_escape(pp->contenttype);
+ if(!escaped) {
ret = CURLE_OUT_OF_MEMORY;
goto nomem;
}
- DATA1(" CURLFORM_CONTENTTYPE, \"%s\",", e);
- free(e);
+ DATA1(" CURLFORM_CONTENTTYPE, \"%s\",", escaped);
}
}
DATA0(" CURLFORM_END);");
}
nomem:
+ Curl_safefree(escaped);
return ret;
}
struct curl_slist *list)
{
CURLcode ret = CURLE_OK;
+ char *escaped = NULL;
bool skip = FALSE;
ret = curl_easy_setopt(curl, tag, list);
CLEAN1("curl_slist_free_all(slist%d);", i);
CLEAN1("slist%d = NULL;", i);
for(s=list; s; s=s->next) {
- char *e = c_escape(s->data);
- if(!e) {
+ Curl_safefree(escaped);
+ escaped = c_escape(s->data);
+ if(!escaped) {
ret = CURLE_OUT_OF_MEMORY;
goto nomem;
}
- DATA3("slist%d = curl_slist_append(slist%d, \"%s\");", i, i, e);
- free(e);
+ DATA3("slist%d = curl_slist_append(slist%d, \"%s\");", i, i, escaped);
}
CODE2("curl_easy_setopt(hnd, %s, slist%d);", name, i);
}
nomem:
+ Curl_safefree(escaped);
return ret;
}
bool remark = FALSE;
bool skip = FALSE;
bool escape = FALSE;
+ char *escaped = NULL;
CURLcode ret = CURLE_OK;
va_start(arg, tag);
REM2("%s set to a %s", name, value);
else {
if(escape) {
- char *escaped = c_escape(value);
+ escaped = c_escape(value);
if(!escaped) {
ret = CURLE_OUT_OF_MEMORY;
goto nomem;
}
CODE2("curl_easy_setopt(hnd, %s, \"%s\");", name, escaped);
- free(escaped);
}
else
CODE2("curl_easy_setopt(hnd, %s, %s);", name, value);
}
nomem:
+ Curl_safefree(escaped);
return ret;
}