diff options
author | 2004-12-08 19:54:11 +0000 | |
---|---|---|
committer | 2004-12-08 19:54:11 +0000 | |
commit | a92c85914c01a09e09daff6f9e19c9a9da610298 (patch) | |
tree | 011663c4fd303984cd4297300408559ba3bd00cd | |
parent | avoid complaining twice when we fail to load a file, and fix a gcc (diff) | |
download | wireguard-openbsd-a92c85914c01a09e09daff6f9e19c9a9da610298.tar.xz wireguard-openbsd-a92c85914c01a09e09daff6f9e19c9a9da610298.zip |
check the return value of a strdup() call and return an error on
failure
from Joris Vink
-rw-r--r-- | usr.bin/cvs/file.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 1c1d7dd9445..670f5c20d95 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.41 2004/12/08 19:44:28 jfb Exp $ */ +/* $OpenBSD: file.c,v 1.42 2004/12/08 19:54:11 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -946,6 +946,12 @@ cvs_file_getname(const char *name) } fnp->cf_name = strdup(name); + if (fnp->cf_name == NULL) { + cvs_log(LP_ERRNO, "failed to duplicate name"); + free(fnp); + return (NULL); + } + fnp->cf_ref = 1; SLIST_INSERT_HEAD(&(cvs_fnht[h]), fnp, cf_list); } |