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;
|
curl_httppost *next = cur->next;
|
||||||
if (cur->contenttype)
|
if (cur->contenttype)
|
||||||
free(cur->contenttype);
|
free(cur->contenttype);
|
||||||
if (cur->contents && cur->flags & HTTPPOST_FILENAME)
|
if (cur->contents)
|
||||||
free(cur->contents);
|
free(cur->contents);
|
||||||
if (cur->buffer)
|
if (cur->buffer)
|
||||||
free(cur->buffer);
|
free(cur->buffer);
|
||||||
|
@ -71,23 +71,25 @@ class NodeCurlHttppost
|
||||||
|
|
||||||
void set(int field, char *value, long length)
|
void set(int field, char *value, long length)
|
||||||
{
|
{
|
||||||
|
value = strndup(value, length);
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case NAME:
|
case NAME:
|
||||||
value = strndup(value, length);
|
|
||||||
last->name = value;
|
last->name = value;
|
||||||
last->namelength = length;
|
last->namelength = length;
|
||||||
break;
|
break;
|
||||||
case TYPE:
|
case TYPE:
|
||||||
value = strndup(value, length);
|
|
||||||
last->contenttype = value;
|
last->contenttype = value;
|
||||||
break;
|
break;
|
||||||
case FILE:
|
case FILE:
|
||||||
value = strndup(value, length);
|
|
||||||
last->flags |= HTTPPOST_FILENAME;
|
last->flags |= HTTPPOST_FILENAME;
|
||||||
case CONTENTS:
|
case CONTENTS:
|
||||||
last->contents = value;
|
last->contents = value;
|
||||||
last->contentslength = length;
|
last->contentslength = length;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
// `default` should never be reached.
|
||||||
|
free(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue