diff --git a/include/swift/Demangling/Demangler.h b/include/swift/Demangling/Demangler.h index 3616ff426af86..fdff286bd8f4e 100644 --- a/include/swift/Demangling/Demangler.h +++ b/include/swift/Demangling/Demangler.h @@ -140,7 +140,7 @@ class NodeFactory { #endif // Do we have enough space in the current slab? - if (CurPtr + ObjectSize > End) { + if (!CurPtr || CurPtr + ObjectSize > End) { // No. We have to malloc a new slab. // We double the slab size for each allocated slab. SlabSize = std::max(SlabSize * 2, ObjectSize + alignof(T));