From 4cfbe22de224fd647bfd2595f9d1be3194893727 Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Sat, 21 Dec 2024 17:00:00 +0000
Subject: [PATCH] (editsearch.c) fix uninitialized value and null pointer dereference
Make Static Analyzer happy.
/tmp/portage/app-misc/mc-9999/work/mc-9999/src/editor/editsearch.c:124:38: warning: Array access (from variable 'search_text') results in a null pointer dereference [clang-analyzer-core.NullDereference]
124 | if (dialog_result == B_CANCEL || search_text[0] == '\0')
| ^
src/editor/editsearch.c:126:9: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
126 | g_free (search_text);
| ^
Found by Clang-19 Static Analyzer
Signed-off-by: Andreas Mohr <and@gmx.li>
---
src/editor/editsearch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/editor/editsearch.c b/src/editor/editsearch.c
index 72f2a53e6..229c505f0 100644
a
|
b
|
edit_search_options_t edit_search_options = { |
75 | 75 | static gboolean |
76 | 76 | edit_dialog_search_show (WEdit *edit) |
77 | 77 | { |
78 | | char *search_text; |
| 78 | char *search_text = NULL; |
79 | 79 | size_t num_of_types = 0; |
80 | 80 | gchar **list_of_types; |
81 | 81 | int dialog_result; |
… |
… |
edit_dialog_search_show (WEdit *edit) |
121 | 121 | |
122 | 122 | g_strfreev (list_of_types); |
123 | 123 | |
124 | | if (dialog_result == B_CANCEL || search_text[0] == '\0') |
| 124 | if (dialog_result == B_CANCEL || search_text == NULL || search_text[0] == '\0') |
125 | 125 | { |
126 | 126 | g_free (search_text); |
127 | 127 | return FALSE; |