From 93d6232502a892a81275c590a3901b3791288078 Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Wed, 6 Apr 2005 03:27:55 +0000 Subject: make sure we don't try and return csp->cs_str when cvs_strtab_insert() fails. ok jfb@ --- usr.bin/cvs/strtab.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/cvs/strtab.c b/usr.bin/cvs/strtab.c index ca39ffae7d7..810162f72db 100644 --- a/usr.bin/cvs/strtab.c +++ b/usr.bin/cvs/strtab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtab.c,v 1.3 2005/03/29 15:04:45 joris Exp $ */ +/* $OpenBSD: strtab.c,v 1.4 2005/04/06 03:27:54 joris Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau * All rights reserved. @@ -75,10 +75,12 @@ cvs_strdup(const char *s) { struct cvs_str *csp; - if ((csp = cvs_strtab_lookup(s)) == NULL) - csp = cvs_strtab_insert(s); - else + if ((csp = cvs_strtab_lookup(s)) == NULL) { + if ((csp = cvs_strtab_insert(s)) == NULL) + return (NULL); + } else { csp->cs_ref++; + } return (csp->cs_str); } -- cgit v1.2.3