aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/procps.c3
-rw-r--r--libbb/xfuncs_printf.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/libbb/procps.c b/libbb/procps.c
index 3d335b37b..71ad071e6 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -554,8 +554,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
break;
if (flags & PSSCAN_ARGVN) {
sp->argv_len = n;
- sp->argv0 = xmalloc(n + 1);
- memcpy(sp->argv0, buf, n + 1);
+ sp->argv0 = xmemdup(buf, n + 1);
/* sp->argv0[n] = '\0'; - buf has it */
} else {
sp->argv_len = 0;
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index e4ac6a002..73488908d 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -112,6 +112,11 @@ char* FAST_FUNC xstrndup(const char *s, int n)
return memcpy(t, s, n);
}
+void* FAST_FUNC xmemdup(const void *s, int n)
+{
+ return memcpy(xmalloc(n), s, n);
+}
+
// Die if we can't open a file and return a FILE* to it.
// Notice we haven't got xfread(), This is for use with fscanf() and friends.
FILE* FAST_FUNC xfopen(const char *path, const char *mode)