summaryrefslogtreecommitdiff
path: root/usr.bin/diff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-06-17 20:50:11 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-06-17 20:50:11 +0000
commit678e74485fca68da752d344aaf34a3b683ef62aa (patch)
tree4996d56ac838f9ef74b447bfde5430dd0d348b2d /usr.bin/diff
parent983808927c0137519341c635c217e725ef8692c2 (diff)
Use strdup in xstrdup; from Fritjof Bornebusch.
Diffstat (limited to 'usr.bin/diff')
-rw-r--r--usr.bin/diff/xmalloc.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/usr.bin/diff/xmalloc.c b/usr.bin/diff/xmalloc.c
index 2eccb0fd63a..5d1483eaff7 100644
--- a/usr.bin/diff/xmalloc.c
+++ b/usr.bin/diff/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.6 2015/04/29 04:00:25 deraadt Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.7 2015/06/17 20:50:10 nicm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -73,12 +73,10 @@ xfree(void *ptr)
char *
xstrdup(const char *str)
{
- size_t len;
char *cp;
- len = strlen(str) + 1;
- cp = xmalloc(len);
- strlcpy(cp, str, len);
+ if ((cp = strdup(str)) == NULL)
+ err(1, "xstrdup");
return cp;
}