Module Name: src Committed By: shm Date: Thu Sep 21 13:46:12 UTC 2023
Modified Files: src/lib/libc/gen: getcap.c Log Message: Fix memory leak in getent() Memory was not freed if record was not found To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/lib/libc/gen/getcap.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/gen/getcap.c diff -u src/lib/libc/gen/getcap.c:1.57 src/lib/libc/gen/getcap.c:1.58 --- src/lib/libc/gen/getcap.c:1.57 Sun Jun 18 03:56:39 2017 +++ src/lib/libc/gen/getcap.c Thu Sep 21 13:46:12 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: getcap.c,v 1.57 2017/06/18 03:56:39 manu Exp $ */ +/* $NetBSD: getcap.c,v 1.58 2023/09/21 13:46:12 shm Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94"; #else -__RCSID("$NetBSD: getcap.c,v 1.57 2017/06/18 03:56:39 manu Exp $"); +__RCSID("$NetBSD: getcap.c,v 1.58 2023/09/21 13:46:12 shm Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -502,8 +502,10 @@ getent(char **cap, size_t *len, const ch break; } - if (!foundit) + if (!foundit) { + free(record); return -1; + } /* * Got the capability record, but now we have to expand all tc=name