lib/util.c:493:28: warning: The left operand of '!=' is a garbage value due to array index out of bounds [clang-analyzer-core.UndefinedBinaryOperatorResult]
493 | for (j = units; sfx[j] != NULL; j++)
| ~~~~~~ ^
- verify and limit input 'units' value
Found by Clang-19 Static Analyzer.
Reported-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <vmail.ru>
/tmp/portage/app-misc/mc-9999/work/mc-9999/lib/widget/quick.c:150:9: warning: Potential leak of memory pointed to by 'label.quick_widget' [clang-analyzer-unix.Malloc]
150 | return;
| ^
Found by Clang-19 Static Analyzer.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Make Static Analyzer happy.
lib/widget/listbox.c:119:51: warning: Division by zero [clang-analyzer-core.DivideZero]
119 | line = 1 + ((l->current * (w->lines - 2)) / length);
Found by Clang-19 Static Analyzer.
Reported-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
quick.c:432:28: runtime error: member access within null pointer of type 'Widget' (aka 'struct Widget')
#0 in quick_dialog_skip lib/widget/quick.c:432:28
#1 in file_mask_dialog src/filemanager/filegui.c:1462:19
#2 in do_confirm_copy_move src/filemanager/file.c:1977:11
#3 in panel_operate src/filemanager/file.c:3536:16
#4 in copy_cmd src/filemanager/./cmd.h:111:5
#5 in midnight_execute_cmd src/filemanager/filemanager.c:1177:9
#6 in midnight_callback src/filemanager/filemanager.c
#7 in send_message lib/widget/../../lib/widget/widget-common.h:255:15
#8 in buttonbar_call lib/widget/buttonbar.c:157:15
#9 in buttonbar_callback lib/widget/buttonbar.c:174:42
#10 in send_message lib/widget/../../lib/widget/widget-common.h:255:15
#11 in group_handle_hotkey lib/widget/group.c:566:23
#12 in group_default_callback lib/widget/group.c:640:16
#13 in dlg_default_callback lib/widget/dialog.c:370:16
#14 in midnight_callback src/filemanager/filemanager.c:1615:16
#15 in send_message lib/widget/../../lib/widget/widget-common.h:255:15
#16 in group_handle_key lib/widget/group.c:503:15
#17 in group_default_callback lib/widget/group.c:637:16
#18 in dlg_key_event lib/widget/dialog.c:252:19
#19 in dlg_process_event lib/widget/dialog.c:539:9
#20 in frontend_dlg_run lib/widget/dialog.c:321:9
#21 in dlg_run lib/widget/dialog.c:573:5
#22 in do_nc src/filemanager/filemanager.c:1826:16
#23 in main src/main.c:469:21
#24 in <null> <null>
#25 in __libc_start_main <null>
#26 in _start <null>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior quick.c:432:28.
Found by Clang-19 Static Analyzer.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Make Static Analyzer happy.
Bug Group Bug Type File Function/Method Line
Logic error Garbage return value src/filemanager/boxes.c cd_box 1236
Logic error Garbage return value lib/widget/wtools.c fg_input_dialog_help 198
Found by Clang-19 Static Analyzer.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (bg_message): use query_dialog() instead of fg_message().
* (message): likewise.
* (fg_message): isn't used anymore. Remove.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Refactoring.
* (mc_search_line_t): rename from edit_search_line_t and move to
lib/search.h.
* (mc_search_get_line_type): rename from edit_get_search_line_type()
and move to lib/search/regex.c.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
* lib/intprops.h: new file.
* src/vfs/tar/tar-internal.h: include intprops.h, remove macros
defined there.
* src/vfs/tar/tar-sparse.c: remove macro, defined in intprops.h.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Sync with gnulib 64ddc975e72cb55d2b2d755c25603bd70312aa5e:
This patch alters xstrtoumax behavior slightly, in areas are not
likely to affect any real callers, by making xstrtoumax behave more
like the system strtol. In particular, it lets xstrtoumax support
bases other than those required by POSIX, if the underlying
implementation does; this removes the need for an g_assert().
* lib/strutil/strtol.c: Do not include stdio.h.
(xstrtoumax): Use same parameter names as POSIX, to make it
easier for outsiders to follow. Do not require the base to be 0-36,
as the underlying implementation is allowed to support other bases.
Sync with gnulib 16b33e6649425fcdce095f262da98b539d2f7448.
* (xstrtoumax): Don't update *endptr if strtol doesn't.
Also, if the underlying strtol gives an unusual error number and
sets *endpnr = nptr, assume that's an error not a missing number.
Sync with gnulib bd1e981434c98751b1106a1744e77a27317b52b3
* (xstrtoumax): Stop worrying about hypothetical implementations that
are causing more confusion than the code is worth. Instead, go back
more to old way of doing things. None of this matters for practical
applications.
Add commemt.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This function is present at least in glib-2.43.92:
../../lib/glibcompat.c:69:1: error: static declaration of 'g_direct_equal' follows non-static declaration
69 | g_direct_equal (gconstpointer v1, gconstpointer v2)
| ^~~~~~~~~~~~~~
In file included from /home/zaytsev/opt/glib/include/glib-2.0/glib.h:50,
from ../../lib/global.h:10,
from ../../lib/glibcompat.c:36:
/home/zaytsev/opt/glib/include/glib-2.0/glib/ghash.h:180:10: note: previous declaration of 'g_direct_equal' was here
180 | gboolean g_direct_equal (gconstpointer v1,
| ^~~~~~~~~~~~~~
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
../../../src/filemanager/file.c:2402:61: warning: variable 'attrs' may be uninitialized when used here [-Wconditional-uninitialized]
while (attrs_ok && mc_fsetflags (dst_vpath, attrs) != 0 && !ctx->skip_all)
^~~~~
../../../src/filemanager/file.c:2266:24: note: initialize the variable 'attrs' to silence this warning
unsigned long attrs;
^
= 0
../../../src/filemanager/file.c:3227:38: warning: variable 'attrs' may be uninitialized when used here [-Wconditional-uninitialized]
mc_fsetflags (dst_vpath, attrs);
^~~~~
../../../src/filemanager/file.c:2942:24: note: initialize the variable 'attrs' to silence this warning
unsigned long attrs;
^
= 0
../../../lib/strutil/tokenize.c:163:44: warning: variable 'delimopen' may be uninitialized when used here [-Wconditional-uninitialized]
if (nestdelim != 0 && string[i] == delimopen)
^~~~~~~~~
../../../lib/strutil/tokenize.c:72:19: note: initialize the variable 'delimopen' to silence this warning
char delimopen;
^
= '\0'
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>