Module Name: src
Committed By: kre
Date: Sun Mar 13 01:44:37 UTC 2022
Modified Files:
src/lib/libc/stdlib: hcreate.c
Log Message:
Avoid referencing uninit'd memory.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/stdlib/hcreate.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/stdlib/hcreate.c
diff -u src/lib/libc/stdlib/hcreate.c:1.12 src/lib/libc/stdlib/hcreate.c:1.13
--- src/lib/libc/stdlib/hcreate.c:1.12 Sat Mar 12 17:31:39 2022
+++ src/lib/libc/stdlib/hcreate.c Sun Mar 13 01:44:37 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: hcreate.c,v 1.12 2022/03/12 17:31:39 christos Exp $ */
+/* $NetBSD: hcreate.c,v 1.13 2022/03/13 01:44:37 kre Exp $ */
/*
* Copyright (c) 2001 Christopher G. Demetriou
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: hcreate.c,v 1.12 2022/03/12 17:31:39 christos Exp $");
+__RCSID("$NetBSD: hcreate.c,v 1.13 2022/03/13 01:44:37 kre Exp $");
#endif /* LIBC_SCCS and not lint */
#if !defined(lint)
@@ -124,6 +124,7 @@ hcreate_r(size_t nel, struct hsearch_dat
/* Allocate the table. */
head->size = nel;
head->filled = 0;
+ table = NULL;
errno = reallocarr(&table, nel, sizeof(*table));
if (errno)
return 0;