mirror of
https://github.com/curl/curl.git
synced 2026-08-25 11:13:32 +03:00
tool: replace three malloc + copy with memdup0
The function already existed for private use in var.c Closes #18185
This commit is contained in:
parent
a7bacfe6e0
commit
b3b7d65239
5 changed files with 21 additions and 24 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include "tool_doswin.h"
|
||||
#include "tool_urlglob.h"
|
||||
#include "tool_vms.h"
|
||||
#include "tool_strdup.h"
|
||||
#include "memdebug.h" /* keep this as LAST include */
|
||||
|
||||
#define GLOBERROR(string, column, code) \
|
||||
|
|
@ -45,13 +46,10 @@ static CURLcode glob_fixed(struct URLGlob *glob, char *fixed, size_t len)
|
|||
if(!pat->content.Set.elements)
|
||||
return GLOBERROR("out of memory", 0, CURLE_OUT_OF_MEMORY);
|
||||
|
||||
pat->content.Set.elements[0] = malloc(len + 1);
|
||||
pat->content.Set.elements[0] = memdup0(fixed, len);
|
||||
if(!pat->content.Set.elements[0])
|
||||
return GLOBERROR("out of memory", 0, CURLE_OUT_OF_MEMORY);
|
||||
|
||||
memcpy(pat->content.Set.elements[0], fixed, len);
|
||||
pat->content.Set.elements[0][len] = 0;
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue