Bug Summary

File:src/fbox.c
Warning:line 89, column 24
Dereference of null pointer

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name fbox.c -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 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/kfp/aldor/aldor/aldor/src -fcoverage-compilation-dir=/home/kfp/aldor/aldor/aldor/src -resource-dir /usr/local/lib/clang/18 -D PACKAGE_NAME="aldor" -D PACKAGE_TARNAME="aldor" -D PACKAGE_VERSION="1.4.0" -D PACKAGE_STRING="aldor 1.4.0" -D PACKAGE_BUGREPORT="aldor@xinutec.org" -D PACKAGE_URL="" -D PACKAGE="aldor" -D VERSION="1.4.0" -D YYTEXT_POINTER=1 -D HAVE_STDIO_H=1 -D HAVE_STDLIB_H=1 -D HAVE_STRING_H=1 -D HAVE_INTTYPES_H=1 -D HAVE_STDINT_H=1 -D HAVE_STRINGS_H=1 -D HAVE_SYS_STAT_H=1 -D HAVE_SYS_TYPES_H=1 -D HAVE_UNISTD_H=1 -D STDC_HEADERS=1 -D HAVE_LIBREADLINE=1 -D HAVE_READLINE_READLINE_H=1 -D HAVE_READLINE_HISTORY=1 -D HAVE_READLINE_HISTORY_H=1 -D USE_GLOOP_SHELL=1 -D GENERATOR_COROUTINES=0 -D HAVE_DLFCN_H=1 -D LT_OBJDIR=".libs/" -I . -D VCSVERSION="2c53e759f1e00e345f8b172e7139debda72fda13" -internal-isystem /usr/local/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-empty-body -Wno-enum-compare -Wno-missing-field-initializers -Wno-unused -Wno-unused-parameter -Wno-error=format -Wno-error=type-limits -Wno-error=strict-aliasing -Wno-sign-compare -Wno-error=shift-negative-value -Wno-error=clobbered -std=c99 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2026-01-15-223856-845667-1 -x c fbox.c
1#include "axlobs.h"
2#include "store.h"
3#include "fbox.h"
4
5FoamBox
6fboxNewEmpty(FoamTag tag)
7{
8 FoamBox newFB;
9
10 newFB = (FoamBox) stoAlloc(OB_Other0, sizeof(struct foamBox));
11 newFB->tag = tag;
12 newFB->l = listNil(Foam)((FoamList) 0);
13 newFB->argc = 0;
14 newFB->initial = 0;
15
16 return newFB;
17}
18
19FoamBox
20fboxNew(Foam foam)
21{
22 FoamBox newFB;
23
24 if (foam == NULL((void*)0)) return NULL((void*)0);
25
26 newFB = fboxNewEmpty(foamTag(foam)((foam)->hdr.tag));
27 newFB->initial = foam;
28 newFB->argc = foamArgc(foam)((foam)->hdr.argc) - foamNaryStart(newFB->tag);
29
30 return newFB;
31}
32
33void
34fboxFree(FoamBox fbox)
35{
36 listFree(Foam)(Foam_listPointer->Free)(fbox->l);
37 stoFree(fbox);
38}
39
40int
41fboxAdd(FoamBox fbox, Foam foam)
42{
43 fbox->l = listCons(Foam)(Foam_listPointer->Cons)(foam, fbox->l);
44 return fbox->argc++;
45}
46
47Foam
48fboxMake(FoamBox fbox)
49{
50 Foam newFoam;
51 int i=0;
52 FoamList l;
53
54 if (fbox->l == listNil(Foam)((FoamList) 0)) {
55 Foam ret;
56 if (fbox->initial)
57 ret = fbox->initial;
58 else
59 ret = foamNewEmpty(fbox->tag, int0((int) 0));
60 stoFree(fbox);
61 return ret;
62 }
63
64 newFoam = foamNewEmpty(fbox->tag, fbox->argc + foamNaryStart(fbox->tag));
65
66 if (fbox->initial)
67 for(i=0; i<foamArgc(fbox->initial)((fbox->initial)->hdr.argc); i++)
68 foamArgv(newFoam)((newFoam)->foamGen.argv)[i].code =
69 foamArgv(fbox->initial)((fbox->initial)->foamGen.argv)[i].code;
70 fbox->l = listNReverse(Foam)(Foam_listPointer->NReverse)(fbox->l);
71 for (l = fbox->l; l; l = cdr(l)((l)->rest), i++)
72 foamArgv(newFoam)((newFoam)->foamGen.argv)[i].code = car(l)((l)->first);
73
74 if (fbox->initial) foamFreeNode(fbox->initial);
75 listFree(Foam)(Foam_listPointer->Free)(fbox->l);
76 stoFree(fbox);
77 return newFoam;
78}
79
80Foam
81fboxNth(FoamBox fbox, int n)
82{
83 int initArgc;
84 if (!fbox->initial)
1
Assuming field 'initial' is null
2
Taking true branch
85 initArgc = 0;
86 else
87 initArgc = foamArgc(fbox->initial)((fbox->initial)->hdr.argc) - foamNaryStart(fbox->tag);
88 if (n < initArgc)
3
Assuming 'n' is < 'initArgc'
4
Taking true branch
89 return foamArgv(fbox->initial)((fbox->initial)->foamGen.argv)[n + foamNaryStart(fbox->tag)].code;
5
Dereference of null pointer
90 else {
91 int i = fbox->argc - n - 1;
92 return listElt(Foam)(Foam_listPointer->Elt)(fbox->l, i);
93 }
94}
95
96