From 3db339be14827dbe0fb571bebb20d1e351d1a49e Mon Sep 17 00:00:00 2001 From: rumble Date: Tue, 10 Aug 2004 02:27:26 +0000 Subject: [PATCH] Avoid dereferencing/free()ing invalid pointers if the random device cannot be opened. OK'd by elric. --- sbin/cgdconfig/utils.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sbin/cgdconfig/utils.c b/sbin/cgdconfig/utils.c index 371c5f7de415..8a909b98a5b5 100644 --- a/sbin/cgdconfig/utils.c +++ b/sbin/cgdconfig/utils.c @@ -1,4 +1,4 @@ -/* $NetBSD: utils.c,v 1.3 2003/09/23 17:24:46 cb Exp $ */ +/* $NetBSD: utils.c,v 1.4 2004/08/10 02:27:26 rumble Exp $ */ /*- * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #ifndef lint -__RCSID("$NetBSD: utils.c,v 1.3 2003/09/23 17:24:46 cb Exp $"); +__RCSID("$NetBSD: utils.c,v 1.4 2004/08/10 02:27:26 rumble Exp $"); #endif #include @@ -464,11 +464,8 @@ bits_cget(const char *fn, int len) FILE *f; f = fopen(fn, "r"); - if (!f) { - free(bits->text); - free(bits); + if (!f) return NULL; - } bits = bits_fget(f, len); fclose(f);