Always make string copy for multi postdata.
This commit is contained in:
parent
8de753eec9
commit
f02c0a6fbf
1 changed files with 6 additions and 4 deletions
|
@ -38,7 +38,7 @@ class NodeCurlHttppost
|
|||
curl_httppost *next = cur->next;
|
||||
if (cur->contenttype)
|
||||
free(cur->contenttype);
|
||||
if (cur->contents && cur->flags & HTTPPOST_FILENAME)
|
||||
if (cur->contents)
|
||||
free(cur->contents);
|
||||
if (cur->buffer)
|
||||
free(cur->buffer);
|
||||
|
@ -71,23 +71,25 @@ class NodeCurlHttppost
|
|||
|
||||
void set(int field, char *value, long length)
|
||||
{
|
||||
value = strndup(value, length);
|
||||
switch (field) {
|
||||
case NAME:
|
||||
value = strndup(value, length);
|
||||
last->name = value;
|
||||
last->namelength = length;
|
||||
break;
|
||||
case TYPE:
|
||||
value = strndup(value, length);
|
||||
last->contenttype = value;
|
||||
break;
|
||||
case FILE:
|
||||
value = strndup(value, length);
|
||||
last->flags |= HTTPPOST_FILENAME;
|
||||
case CONTENTS:
|
||||
last->contents = value;
|
||||
last->contentslength = length;
|
||||
break;
|
||||
default:
|
||||
// `default` should never be reached.
|
||||
free(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue