Skip to content

Commit 7145afb

Browse files
committed
[Demangler] Null-check a pointer before using it in arithmetic
This addresses a UBSan -fsanitize=null diagnostic seen when compiling the stdlib: runtime error: applying non-zero offset 128 to null pointer
1 parent fd3e3cf commit 7145afb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/swift/Demangling/Demangler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class NodeFactory {
140140
#endif
141141

142142
// Do we have enough space in the current slab?
143-
if (CurPtr + ObjectSize > End) {
143+
if (!CurPtr || CurPtr + ObjectSize > End) {
144144
// No. We have to malloc a new slab.
145145
// We double the slab size for each allocated slab.
146146
SlabSize = std::max(SlabSize * 2, ObjectSize + alignof(T));

0 commit comments

Comments
 (0)