Bug Summary

File:src/gnu/usr.bin/binutils/gdb/frame-unwind.c
Warning:line 52, column 17
Null pointer passed as 1st argument to memory set 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 frame-unwind.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/frame-unwind.c
1/* Definitions for frame unwinder, for GDB, the GNU debugger.
2
3 Copyright 2003, 2004 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#include "defs.h"
23#include "frame.h"
24#include "frame-unwind.h"
25#include "gdb_assert.h"
26#include "dummy-frame.h"
27#include "gdb_obstack.h"
28
29static struct gdbarch_data *frame_unwind_data;
30
31struct frame_unwind_table_entry
32{
33 frame_unwind_sniffer_ftype *sniffer;
34 const struct frame_unwind *unwinder;
35 struct frame_unwind_table_entry *next;
36};
37
38struct frame_unwind_table
39{
40 struct frame_unwind_table_entry *list;
41 /* The head of the OSABI part of the search list. */
42 struct frame_unwind_table_entry **osabi_head;
43};
44
45static void *
46frame_unwind_init (struct obstack *obstack)
47{
48 struct frame_unwind_table *table
49 = OBSTACK_ZALLOC (obstack, struct frame_unwind_table)(memset (__extension__ ({ struct obstack *__h = ((obstack)); __extension__
({ struct obstack *__o = (__h); int __len = ((sizeof (struct
frame_unwind_table))); if (__o->chunk_limit - __o->next_free
< __len) _obstack_newchunk (__o, __len); ((__o)->next_free
+= (__len)); (void) 0; }); __extension__ ({ struct obstack *
__o1 = (__h); void *value; value = (void *) __o1->object_base
; if (__o1->next_free == value) __o1->maybe_empty_object
= 1; __o1->next_free = (((((__o1->next_free) - (char *
) 0)+__o1->alignment_mask) & ~ (__o1->alignment_mask
)) + (char *) 0); if (__o1->next_free - (char *)__o1->chunk
> __o1->chunk_limit - (char *)__o1->chunk) __o1->
next_free = __o1->chunk_limit; __o1->object_base = __o1
->next_free; value; }); }), 0, sizeof (struct frame_unwind_table
)))
;
1
Assuming the condition is false
2
Taking false branch
3
Assuming 'value' is not equal to field 'next_free'
4
Taking false branch
5
Assuming the condition is false
6
Taking false branch
50 /* Start the table out with a few default sniffers. OSABI code
51 can't override this. */
52 table->list = OBSTACK_ZALLOC (obstack, struct frame_unwind_table_entry)(memset (__extension__ ({ struct obstack *__h = ((obstack)); __extension__
({ struct obstack *__o = (__h); int __len = ((sizeof (struct
frame_unwind_table_entry))); if (__o->chunk_limit - __o->
next_free < __len) _obstack_newchunk (__o, __len); ((__o)->
next_free += (__len)); (void) 0; }); __extension__ ({ struct obstack
*__o1 = (__h); void *value; value = (void *) __o1->object_base
; if (__o1->next_free == value) __o1->maybe_empty_object
= 1; __o1->next_free = (((((__o1->next_free) - (char *
) 0)+__o1->alignment_mask) & ~ (__o1->alignment_mask
)) + (char *) 0); if (__o1->next_free - (char *)__o1->chunk
> __o1->chunk_limit - (char *)__o1->chunk) __o1->
next_free = __o1->chunk_limit; __o1->object_base = __o1
->next_free; value; }); }), 0, sizeof (struct frame_unwind_table_entry
)))
;
7
Assuming the condition is false
8
Taking false branch
9
Taking true branch
10
Assuming the condition is false
11
Taking false branch
12
Null pointer passed as 1st argument to memory set function
53 table->list->unwinder = dummy_frame_unwind;
54 /* The insertion point for OSABI sniffers. */
55 table->osabi_head = &table->list->next;
56 return table;
57}
58
59void
60frame_unwind_append_sniffer (struct gdbarch *gdbarch,
61 frame_unwind_sniffer_ftype *sniffer)
62{
63 struct frame_unwind_table *table = gdbarch_data (gdbarch, frame_unwind_data);
64 struct frame_unwind_table_entry **ip;
65
66 /* Find the end of the list and insert the new entry there. */
67 for (ip = table->osabi_head; (*ip) != NULL((void*)0); ip = &(*ip)->next);
68 (*ip) = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind_table_entry)((struct frame_unwind_table_entry *) gdbarch_obstack_zalloc (
(gdbarch), sizeof (struct frame_unwind_table_entry)))
;
69 (*ip)->sniffer = sniffer;
70}
71
72void
73frame_unwind_prepend_unwinder (struct gdbarch *gdbarch,
74 const struct frame_unwind *unwinder)
75{
76 struct frame_unwind_table *table = gdbarch_data (gdbarch, frame_unwind_data);
77 struct frame_unwind_table_entry *entry;
78
79 /* Insert the new entry at the start of the list. */
80 entry = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind_table_entry)((struct frame_unwind_table_entry *) gdbarch_obstack_zalloc (
(gdbarch), sizeof (struct frame_unwind_table_entry)))
;
81 entry->unwinder = unwinder;
82 entry->next = (*table->osabi_head);
83 (*table->osabi_head) = entry;
84}
85
86const struct frame_unwind *
87frame_unwind_find_by_frame (struct frame_info *next_frame, void **this_cache)
88{
89 int i;
90 struct gdbarch *gdbarch = get_frame_arch (next_frame);
91 struct frame_unwind_table *table = gdbarch_data (gdbarch, frame_unwind_data);
92 struct frame_unwind_table_entry *entry;
93 for (entry = table->list; entry != NULL((void*)0); entry = entry->next)
94 {
95 if (entry->sniffer != NULL((void*)0))
96 {
97 const struct frame_unwind *desc = NULL((void*)0);
98 desc = entry->sniffer (next_frame);
99 if (desc != NULL((void*)0))
100 return desc;
101 }
102 if (entry->unwinder != NULL((void*)0))
103 {
104 if (entry->unwinder->sniffer (entry->unwinder, next_frame,
105 this_cache))
106 return entry->unwinder;
107 }
108 }
109 internal_error (__FILE__"/usr/src/gnu/usr.bin/binutils/gdb/frame-unwind.c", __LINE__109, "frame_unwind_find_by_frame failed");
110}
111
112extern initialize_file_ftype _initialize_frame_unwind; /* -Wmissing-prototypes */
113
114void
115_initialize_frame_unwind (void)
116{
117 frame_unwind_data = gdbarch_data_register_pre_init (frame_unwind_init);
118}