blob: c2fb4dc8eee9c71cd9d012e0237230389dc82b02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
$NetBSD: patch-src_misc.c,v 1.1 2017/11/11 17:28:39 maya Exp $
use strdup instead of being off by one with our version
of strdup
--- src/misc.c.orig 2006-01-19 22:46:23.000000000 +0000
+++ src/misc.c
@@ -119,9 +119,10 @@ void *xmalloc(size_t size)
char *xstrdup(const char *str)
{
- register char *nstr = (char *)xmalloc(strlen(str));
- /* we should use srtlcpy here instead of strcpy */
- strcpy(nstr, str);
+ register char *nstr = (char *) strdup(str);
+
+ if (nstr == NULL) fatal(_("virtual memory exhausted"));
+
return nstr;
}
|