From f24fdfda12807172b957621e09fd3d2294bdb214 Mon Sep 17 00:00:00 2001 From: job Date: Thu, 9 Apr 2026 17:29:04 +0000 Subject: [PATCH] Check cleared memory allocation and free before exit for consistency From Jan Schreiber, input from Patrick Keshishian OK tb@ --- usr.bin/watch/watch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/watch/watch.c b/usr.bin/watch/watch.c index 1d5f8248fb5..13222480b34 100644 --- a/usr.bin/watch/watch.c +++ b/usr.bin/watch/watch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: watch.c,v 1.37 2025/07/09 21:23:28 job Exp $ */ +/* $OpenBSD: watch.c,v 1.38 2026/04/09 17:29:04 job Exp $ */ /* * Copyright (c) 2025 Job Snijders * Copyright (c) 2000, 2001 Internet Initiative Japan Inc. @@ -446,7 +446,9 @@ start_child() struct child *child; int fds[2]; - child = calloc(1, sizeof(*child)); + if ((child = calloc(1, sizeof(*child))) == NULL) + err(1, "calloc"); + child->bufsiz = sizeof(child->buf); if (pipe(fds) == -1) @@ -910,6 +912,7 @@ quit(void) refresh(); endwin(); free(cmdv); + free(cmdstr); exit(0); }