This is horrible code and at least file leaks in various paths, but that's
for someone else to fix.
found by & ok jsg
-/* $OpenBSD: fortune.c,v 1.64 2024/05/21 05:00:47 jsg Exp $ */
+/* $OpenBSD: fortune.c,v 1.65 2024/09/20 12:52:37 tb Exp $ */
/* $NetBSD: fortune.c,v 1.8 1995/03/23 08:28:40 cgd Exp $ */
/*-
if (was_malloc)
free(path);
path = offensive;
+ offensive = NULL;
file = off_name(file);
was_malloc = true;
}
* we'll pick up the -o file anyway.
*/
if (All_forts && offensive != NULL) {
- path = offensive;
if (was_malloc)
free(path);
+ path = offensive;
offensive = NULL;
was_malloc = true;
DPRINTF(1, (stderr, "\ttrying \"%s\"\n", path));