mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
capture-writer: ftruncate() when creating capture
We risk overwriting existing data leaving our file in a somewhat broken state. So first ftruncate() to zero so we are starting from scratch.
This commit is contained in:
@ -375,6 +375,9 @@ sp_capture_writer_new_from_fd (int fd,
|
||||
g_assert (fd != -1);
|
||||
g_assert (buffer_size % getpagesize() == 0);
|
||||
|
||||
if (ftruncate (fd, 0) != 0)
|
||||
return NULL;
|
||||
|
||||
self = g_new0 (SpCaptureWriter, 1);
|
||||
self->ref_count = 1;
|
||||
self->fd = fd;
|
||||
|
||||
Reference in New Issue
Block a user