From dfd81f1ecb7af59fa78e95326e896fb6e089a8b8 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 24 Jul 2023 17:28:46 -0700 Subject: [PATCH] libsysprof-capture: ensure trailing bit is zero This ensures situations that are not perfectly aligned can still be 1-off checked for a trailing \0 without scanning. --- src/libsysprof-capture/sysprof-capture-writer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libsysprof-capture/sysprof-capture-writer.c b/src/libsysprof-capture/sysprof-capture-writer.c index 4b703d3d..ea9e0538 100644 --- a/src/libsysprof-capture/sysprof-capture-writer.c +++ b/src/libsysprof-capture/sysprof-capture-writer.c @@ -613,6 +613,8 @@ sysprof_capture_writer_add_map (SysprofCaptureWriter *self, _sysprof_strlcpy (ev->filename, filename, len - sizeof *ev); ev->filename[len - sizeof *ev - 1] = '\0'; + ((char*)ev)[len-1] = 0; + self->stat.frame_count[SYSPROF_CAPTURE_FRAME_MAP]++; return true;