From 3614a24446e05f175849895444edfb8a689016c9 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 14 Jan 2024 16:56:04 +0100 Subject: [PATCH] Fix segfault when dbus is disabled (fixes #397) --- zathura/commands.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/zathura/commands.c b/zathura/commands.c index d46d9f5..296ac42 100644 --- a/zathura/commands.c +++ b/zathura/commands.c @@ -546,12 +546,14 @@ bool cmd_exec(girara_session_t* session, girara_list_t* argument_list) { return false; } - const char* bus_name = zathura_dbus_get_name(zathura); - for (size_t idx = 0; idx != girara_list_size(argument_list); ++idx) { - char* value = girara_list_nth(argument_list, idx); - char* s = girara_replace_substring(value, "$DBUS", bus_name); - if (s != NULL) { - girara_list_set_nth(argument_list, idx, s); + if (zathura->dbus != NULL) { + const char* bus_name = zathura_dbus_get_name(zathura); + for (size_t idx = 0; idx != girara_list_size(argument_list); ++idx) { + char* value = girara_list_nth(argument_list, idx); + char* s = girara_replace_substring(value, "$DBUS", bus_name); + if (s != NULL) { + girara_list_set_nth(argument_list, idx, s); + } } }