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.
This commit is contained in:
Christian Hergert
2023-07-24 17:28:46 -07:00
parent d1ae6b7b4a
commit dfd81f1ecb

View File

@ -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;