mirror of
https://github.com/curl/curl.git
synced 2026-08-24 22:23:58 +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
|
|
@ -365,9 +365,7 @@ static void strstore(char **str, const char *newstr, size_t len)
|
|||
DEBUGASSERT(newstr);
|
||||
DEBUGASSERT(str);
|
||||
free(*str);
|
||||
*str = Curl_memdup(newstr, len + 1);
|
||||
if(*str)
|
||||
(*str)[len] = 0;
|
||||
*str = Curl_strndup(newstr, len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue