mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 23:20:54 +00:00
sysprof-dump: Move error handling up to avoid a NULL pointer dereference
`reader` can be `NULL`, but the `NULL` check was done after potentially dereferencing it. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #40
This commit is contained in:
@ -56,7 +56,11 @@ main (gint argc,
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader = sysprof_capture_reader_new (argv[1], &error);
|
if ((reader = sysprof_capture_reader_new (argv[1], &error)) == NULL)
|
||||||
|
{
|
||||||
|
g_printerr ("%s\n", error->message);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
if (list_files)
|
if (list_files)
|
||||||
{
|
{
|
||||||
@ -75,12 +79,6 @@ main (gint argc,
|
|||||||
#define SET_CTR_TYPE(i,t) g_hash_table_insert(ctrtypes, GINT_TO_POINTER(i), GINT_TO_POINTER(t))
|
#define SET_CTR_TYPE(i,t) g_hash_table_insert(ctrtypes, GINT_TO_POINTER(i), GINT_TO_POINTER(t))
|
||||||
#define GET_CTR_TYPE(i) GPOINTER_TO_INT(g_hash_table_lookup(ctrtypes, GINT_TO_POINTER(i)))
|
#define GET_CTR_TYPE(i) GPOINTER_TO_INT(g_hash_table_lookup(ctrtypes, GINT_TO_POINTER(i)))
|
||||||
|
|
||||||
if (reader == NULL)
|
|
||||||
{
|
|
||||||
g_printerr ("%s\n", error->message);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
begin_time = sysprof_capture_reader_get_start_time (reader);
|
begin_time = sysprof_capture_reader_get_start_time (reader);
|
||||||
end_time = sysprof_capture_reader_get_end_time (reader);
|
end_time = sysprof_capture_reader_get_end_time (reader);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user