Commit 4d980b1
committed
Correcting a UBSan error in builder
If a table with optional fields is created before the ds-stack is allocated we get an UBSan error.
The ds stack would normally be allocated when a field is added to the table.
/xxxx/flatcc/src/runtime/builder.c:613:16: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:61:62: note: nonnull attribute specified here
#0 0x600c6b6e in exit_frame /xxxx/flatcc/src/runtime/builder.c:613:9
#1 0x600d4520 in flatcc_builder_end_table /xxxx/flatcc/src/runtime/builder.c:1380:5
#2 0x600a0be8 in optional_scalars_NestedTable_end /xxxx/flatcc/build/Debug/test/optional_scalars_test/generated/optional_scalars_test_builder.h:35:1
#3 0x600a08a7 in create_scalar_stuff /xxxx/flatcc/test/optional_scalars_test/optional_scalars_test.c:27:20
#4 0x600ab4f5 in test /xxxx/flatcc/test/optional_scalars_test/optional_scalars_test.c:176:5
#5 0x600abd1f in main /xxxx/flatcc/test/optional_scalars_test/optional_scalars_test.c:272:9
#6 0xe9186518 (/lib/i386-linux-gnu/libc.so.6+0x21518) (BuildId: 6f8a2d2f90a25e7865aa6fdfd9a7825d62d53f51)
#7 0xe91865f2 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x215f2) (BuildId: 6f8a2d2f90a25e7865aa6fdfd9a7825d62d53f51)
#8 0x6007053a in _start (/xxxx/flatcc/build/Debug/test/optional_scalars_test/optional_scalars_test_d+0x2653a) (BuildId: d47f8a02ee936bc1bc53a0efd6ad360faa6428d7)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /xxxx/flatcc/src/runtime/builder.c:613:16
Signed-off-by: Björn Svensson <[email protected]>1 parent e32c6f6 commit 4d980b1
File tree
3 files changed
+18
-2
lines changed- src/runtime
- test/optional_scalars_test
3 files changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
611 | | - | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
612 | 615 | | |
613 | 616 | | |
614 | 617 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| 57 | + | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| |||
176 | 183 | | |
177 | 184 | | |
178 | 185 | | |
179 | | - | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
71 | 77 | | |
0 commit comments