[sysprof: 4/63] sysprof-dump: Move error handling up to avoid a NULL pointer dereference
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof: 4/63] sysprof-dump: Move error handling up to avoid a NULL pointer dereference
- Date: Sat, 4 Jul 2020 18:29:40 +0000 (UTC)
commit 3eb0f3e964177e20452f98ddff965aac91f0dc82
Author: Philip Withnall <withnall endlessm com>
Date: Tue Jun 30 16:21:38 2020 +0100
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
src/tools/sysprof-dump.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/src/tools/sysprof-dump.c b/src/tools/sysprof-dump.c
index 8b99624..2439490 100644
--- a/src/tools/sysprof-dump.c
+++ b/src/tools/sysprof-dump.c
@@ -56,7 +56,11 @@ main (gint argc,
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)
{
@@ -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 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);
end_time = sysprof_capture_reader_get_end_time (reader);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]