From 14e69527267db7126181a6253497ddf62a03cba7 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 30 Jun 2023 12:43:31 -0700 Subject: [PATCH] libsysprof-profile: clamp to range --- src/libsysprof-profile/sysprof-cpu-usage.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libsysprof-profile/sysprof-cpu-usage.c b/src/libsysprof-profile/sysprof-cpu-usage.c index d29a2545..229f9c8f 100644 --- a/src/libsysprof-profile/sysprof-cpu-usage.c +++ b/src/libsysprof-profile/sysprof-cpu-usage.c @@ -116,6 +116,8 @@ get_cpu_freq (int stat_fd, g_strchug (buf); val = g_ascii_strtoll (buf, NULL, 10); + val = CLAMP (val, .0, max); + return (double)val / max * 100.; }