From: Daniel Stenberg Date: Tue, 30 Dec 2025 22:19:01 +0000 (+0100) Subject: tool_getparam: use memdup0() instead of malloc + copy X-Git-Tag: curl-8_18_0~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37d871af019af07edca5eaa3a47e3731b0a23dab;p=thirdparty%2Fcurl.git tool_getparam: use memdup0() instead of malloc + copy Closes #20118 --- diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 89385af844..7a3f815dff 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -36,6 +36,7 @@ #include "tool_main.h" #include "tool_stderr.h" #include "tool_help.h" +#include "tool_strdup.h" #include "var.h" #define ALLOW_BLANK TRUE @@ -69,13 +70,10 @@ static ParameterError getstrn(char **str, const char *val, if(!allowblank && !val[0]) return PARAM_BLANK_STRING; - *str = curlx_malloc(len + 1); + *str = memdup0(val, len); if(!*str) return PARAM_NO_MEM; - memcpy(*str, val, len); - (*str)[len] = 0; /* null-terminate */ - return PARAM_OK; }