From bef18681cf2312b08d06810ec25d75776bad899c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:27:11 +0100 Subject: [PATCH] Recast: return out early if we have no regions --- src/thirdparty/recast/Recast/Source/RecastLayers.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/thirdparty/recast/Recast/Source/RecastLayers.cpp b/src/thirdparty/recast/Recast/Source/RecastLayers.cpp index 0308639f..a8a59642 100644 --- a/src/thirdparty/recast/Recast/Source/RecastLayers.cpp +++ b/src/thirdparty/recast/Recast/Source/RecastLayers.cpp @@ -222,9 +222,16 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, } } + if (regId == 0) + { + // No regions generated, but without an error. + return true; + } + // Allocate and init layer regions. const int nregs = (int)regId; rdScopedDelete regs((rcLayerRegion*)rdAlloc(sizeof(rcLayerRegion)*nregs, RD_ALLOC_TEMP)); + if (!regs) { ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'regs' (%d).", nregs);