← Commit list

37d871af01

Daniel Stenberg
Daniel Stenberg
2025-12-30
SUCCESS Duration: 255s

Subject

tool_getparam: use memdup0() instead of malloc + copy

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

src/tool_getparam.c+2 -4
@@ -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;
}