mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-capture: wrap strdup to be NULL-safe
This commit is contained in:
committed by
Philip Withnall
parent
6a45f020f7
commit
cef698e658
@ -519,7 +519,7 @@ sysprof_capture_condition_new_where_file (const char *path)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
self->type = SYSPROF_CAPTURE_CONDITION_WHERE_FILE;
|
self->type = SYSPROF_CAPTURE_CONDITION_WHERE_FILE;
|
||||||
self->u.where_file = strdup (path);
|
self->u.where_file = sysprof_strdup (path);
|
||||||
if (self->u.where_file == NULL)
|
if (self->u.where_file == NULL)
|
||||||
{
|
{
|
||||||
free (self);
|
free (self);
|
||||||
|
|||||||
@ -284,7 +284,7 @@ sysprof_capture_reader_new (const char *filename,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->filename = strdup (filename);
|
self->filename = sysprof_strdup (filename);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -1080,7 +1080,7 @@ sysprof_capture_reader_save_as (SysprofCaptureReader *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self->filename == NULL)
|
if (self->filename == NULL)
|
||||||
self->filename = strdup (filename);
|
self->filename = sysprof_strdup (filename);
|
||||||
|
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
@ -1173,7 +1173,7 @@ sysprof_capture_reader_copy (SysprofCaptureReader *self)
|
|||||||
*copy = *self;
|
*copy = *self;
|
||||||
|
|
||||||
copy->ref_count = 1;
|
copy->ref_count = 1;
|
||||||
copy->filename = strdup (self->filename);
|
copy->filename = sysprof_strdup (self->filename);
|
||||||
copy->fd = fd;
|
copy->fd = fd;
|
||||||
copy->end_time = self->end_time;
|
copy->end_time = self->end_time;
|
||||||
copy->st_buf = self->st_buf;
|
copy->st_buf = self->st_buf;
|
||||||
|
|||||||
@ -73,3 +73,5 @@
|
|||||||
if (_p != NULL) \
|
if (_p != NULL) \
|
||||||
(destroy) (_p); \
|
(destroy) (_p); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define sysprof_strdup(s) ((s) ? strdup(s) : NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user