mirror of
https://github.com/curl/curl.git
synced 2026-08-02 02:20:29 +03:00
lib: add and use Curl_strndup()
The Curl_strndup() function is similar to memdup(), but copies 'n' bytes
then adds a terminating null byte ('\0').
Closes #12251
This commit is contained in:
parent
fdaed85b02
commit
d3b3ba35a5
7 changed files with 30 additions and 18 deletions
|
|
@ -603,9 +603,9 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
app passed in a bad combo, so we better check for that first. */
|
||||
if(form->name) {
|
||||
/* copy name (without strdup; possibly not null-terminated) */
|
||||
form->name = Curl_memdup(form->name, form->namelength?
|
||||
form->namelength:
|
||||
strlen(form->name) + 1);
|
||||
form->name = Curl_strndup(form->name, form->namelength?
|
||||
form->namelength:
|
||||
strlen(form->name));
|
||||
}
|
||||
if(!form->name) {
|
||||
return_value = CURL_FORMADD_MEMORY;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue