Bug Summary

File:src/gnu/usr.bin/binutils/gdb/tui/tui-command.c
Warning:line 73, column 12
Null pointer passed as 1st argument to string comparison function

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name tui-command.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/gnu/usr.bin/binutils/obj/gdb -resource-dir /usr/local/lib/clang/13.0.0 -D PIE_DEFAULT=1 -I . -I /usr/src/gnu/usr.bin/binutils/gdb -I /usr/src/gnu/usr.bin/binutils/gdb/config -D LOCALEDIR="/usr/share/locale" -D HAVE_CONFIG_H -I /usr/src/gnu/usr.bin/binutils/gdb/../include/opcode -I ../bfd -I /usr/src/gnu/usr.bin/binutils/gdb/../bfd -I /usr/src/gnu/usr.bin/binutils/gdb/../include -I ../intl -I /usr/src/gnu/usr.bin/binutils/gdb/../intl -D MI_OUT=1 -D TUI=1 -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/gnu/usr.bin/binutils/obj/gdb -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -fcommon -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c /usr/src/gnu/usr.bin/binutils/gdb/tui/tui-command.c
1/* Specific command window processing.
2
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
4 Foundation, Inc.
5
6 Contributed by Hewlett-Packard Company.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24
25#include "defs.h"
26#include <ctype.h>
27#include "tui/tui.h"
28#include "tui/tui-data.h"
29#include "tui/tui-win.h"
30#include "tui/tui-io.h"
31
32#include "gdb_curses.h"
33#include "gdb_string.h"
34
35
36/*****************************************
37** STATIC LOCAL FUNCTIONS FORWARD DECLS **
38******************************************/
39
40
41
42/*****************************************
43** PUBLIC FUNCTIONS **
44******************************************/
45
46/* Dispatch the correct tui function based upon the control character. */
47unsigned int
48tui_dispatch_ctrl_char (unsigned int ch)
49{
50 struct tui_win_info *win_info = tui_win_with_focus ();
51 WINDOW *w = TUI_CMD_WINtui_win_list[CMD_WIN]->generic.handle;
52
53 /*
54 ** If the command window has the logical focus, or no-one does
55 ** assume it is the command window; in this case, pass the
56 ** character on through and do nothing here.
57 */
58 if (win_info == NULL((void*)0) || win_info == TUI_CMD_WINtui_win_list[CMD_WIN])
1
Assuming 'win_info' is not equal to NULL
2
Assuming the condition is false
3
Taking false branch
59 return ch;
60 else
61 {
62 unsigned int c = 0, ch_copy = ch;
63 int i;
64 char *term;
65
66 /* If this is an xterm, page next/prev keys aren't returned
67 ** by keypad as a single char, so we must handle them here.
68 ** Seems like a bug in the curses library?
69 */
70 term = (char *) getenv ("TERM");
4
Value assigned to 'term'
71 for (i = 0; (term && term[i]); i++)
5
Assuming 'term' is null
72 term[i] = toupper (term[i]);
73 if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch))
6
Null pointer passed as 1st argument to string comparison function
74 {
75 unsigned int page_ch = 0;
76 unsigned int tmp_char;
77
78 tmp_char = 0;
79 while (!key_is_end_sequence (tmp_char))
80 {
81 tmp_char = (int) wgetch (w);
82 if (tmp_char == ERR(-1))
83 {
84 return ch;
85 }
86 if (!tmp_char)
87 break;
88 if (tmp_char == 53)
89 page_ch = KEY_PPAGE0523;
90 else if (tmp_char == 54)
91 page_ch = KEY_NPAGE0522;
92 else
93 {
94 return 0;
95 }
96 }
97 ch_copy = page_ch;
98 }
99
100 switch (ch_copy)
101 {
102 case KEY_NPAGE0522:
103 tui_scroll_forward (win_info, 0);
104 break;
105 case KEY_PPAGE0523:
106 tui_scroll_backward (win_info, 0);
107 break;
108 case KEY_DOWN0402:
109 case KEY_SF0520:
110 tui_scroll_forward (win_info, 1);
111 break;
112 case KEY_UP0403:
113 case KEY_SR0521:
114 tui_scroll_backward (win_info, 1);
115 break;
116 case KEY_RIGHT0405:
117 tui_scroll_left (win_info, 1);
118 break;
119 case KEY_LEFT0404:
120 tui_scroll_right (win_info, 1);
121 break;
122 case '\f':
123 tui_refresh_all_win ();
124 break;
125 default:
126 c = ch_copy;
127 break;
128 }
129 return c;
130 }
131}