[file-roller/wip/jtojnar/clang-analysis: 5/8] application: Fix possible null pointer dereference
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/wip/jtojnar/clang-analysis: 5/8] application: Fix possible null pointer dereference
- Date: Tue, 6 Sep 2022 23:42:01 +0000 (UTC)
commit b0eaa6ab30c5da05554cfb1f0c5c13b9177577f4
Author: Jan Tojnar <jtojnar gmail com>
Date: Sat Sep 3 23:45:41 2022 +0200
application: Fix possible null pointer dereference
Discovered with Clang’s scan-build tool:
../../../src/fr-application.c:273:37: warning: Access to field 'data' results in a dereference of a
null pointer (loaded from variable 'file_list') [core.NullDereference]
destination = g_file_get_parent (G_FILE (file_list->data));
^~~~~~~~~~~~~~~~~~~~~~~~
Would occur when empty destination URI was passed to Compress D-Bus method.
Introduced in https://gitlab.gnome.org/GNOME/file-roller/-/commit/34b64f3a897c4b4e8e180c028f326bc921eb08ec
src/fr-application.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/fr-application.c b/src/fr-application.c
index a0097b9c..d448e0cb 100644
--- a/src/fr-application.c
+++ b/src/fr-application.c
@@ -269,13 +269,15 @@ handle_method_call (GDBusConnection *connection,
if ((destination_uri != NULL) && (strcmp (destination_uri, "") != 0))
destination = g_file_new_for_uri (destination_uri);
- else
- destination = g_file_get_parent (G_FILE (file_list->data));
for (i = 0; files[i] != NULL; i++)
file_list = g_list_prepend (file_list, g_file_new_for_uri (files[i]));
file_list = g_list_reverse (file_list);
+ if (destination == NULL && file_list != NULL) {
+ destination = g_file_get_parent (G_FILE (file_list->data));
+ }
+
window = fr_window_new ();
fr_window_use_progress_dialog (FR_WINDOW (window), use_progress_dialog);
fr_window_set_default_dir (FR_WINDOW (window), destination, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]