Module Name: src Committed By: martin Date: Sat Dec 24 17:17:27 UTC 2022
Modified Files: src/usr.sbin/tprof [netbsd-10]: tprof_top.c Log Message: Pull up following revision(s) (requested by christos in ticket #22): usr.sbin/tprof/tprof_top.c: revision 1.8 use malloc instead of alloca so that SSP works. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.7.2.1 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/tprof/tprof_top.c diff -u src/usr.sbin/tprof/tprof_top.c:1.7 src/usr.sbin/tprof/tprof_top.c:1.7.2.1 --- src/usr.sbin/tprof/tprof_top.c:1.7 Fri Dec 16 08:02:04 2022 +++ src/usr.sbin/tprof/tprof_top.c Sat Dec 24 17:17:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_top.c,v 1.7 2022/12/16 08:02:04 ryo Exp $ */ +/* $NetBSD: tprof_top.c,v 1.7.2.1 2022/12/24 17:17:27 martin Exp $ */ /*- * Copyright (c) 2022 Ryo Shimizu <r...@nerv.org> @@ -28,7 +28,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: tprof_top.c,v 1.7 2022/12/16 08:02:04 ryo Exp $"); +__RCSID("$NetBSD: tprof_top.c,v 1.7.2.1 2022/12/24 17:17:27 martin Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -194,7 +194,9 @@ lim_printf(int *lim, const char *fmt, .. if (*lim <= 0) return 0; - p = alloca(*lim + 1); + p = malloc(*lim + 1); + if (p == NULL) + return -1; va_start(ap, fmt); vsnprintf(p, *lim + 1, fmt, ap); @@ -202,6 +204,7 @@ lim_printf(int *lim, const char *fmt, .. written = strlen(p); if (written == 0) { + free(p); *lim = 0; return 0; } @@ -209,6 +212,7 @@ lim_printf(int *lim, const char *fmt, .. fwrite(p, written, 1, stdout); *lim -= written; + free(p); return written; }