From 434a887834ba5eef22b1b45b2cc3092496332677 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Sat, 28 Feb 2026 09:49:55 +0100 Subject: [PATCH] Fix -Wanalyzer-deref-before-check warning in get_message_from_editor Let's add an explicit check. --- src/tools/editor.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tools/editor.c b/src/tools/editor.c index 3c5ee823..70bc13f3 100644 --- a/src/tools/editor.c +++ b/src/tools/editor.c @@ -86,12 +86,18 @@ get_message_from_editor(gchar* message, gchar** returned_message) auto_gchar gchar* editor_with_filename = g_strdup_printf("%s %s", editor, filename); auto_gcharv gchar** editor_argv = g_strsplit(editor_with_filename, " ", 0); + if (!editor_argv || !editor_argv[0]) { + log_error("[Editor] Failed to parse editor command: %s", editor); + return TRUE; + } + // Fork / exec pid_t pid = fork(); if (pid == 0) { - int x = execvp(editor_argv[0], editor_argv); - if (x == -1) { - log_error("[Editor] Failed to exec %s", editor); + if (editor_argv && editor_argv[0]) { + int x = execvp(editor_argv[0], editor_argv); + if (x == -1) + log_error("[Editor] Failed to exec %s", editor); } _exit(EXIT_FAILURE); } else {