From be10e956986ec1c7bba946cf870e401e9fd45279 Mon Sep 17 00:00:00 2001 From: Julius Michaelis Date: Sun, 10 Dec 2017 15:09:51 +0100 Subject: [PATCH] Prevent SEGV on duplicate material names with different case (#1359) --- src/landscape/C4Material.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/landscape/C4Material.cpp b/src/landscape/C4Material.cpp index 5e9f8b5843..b032080ac1 100644 --- a/src/landscape/C4Material.cpp +++ b/src/landscape/C4Material.cpp @@ -331,6 +331,10 @@ int32_t C4MaterialMap::Load(C4Group &hGroup) hGroup.ResetSearch(); int32_t cnt=0; while (hGroup.FindNextEntry(C4CFN_MaterialFiles,entryname)) { + if (cnt >= mat_num) { + Log("Internal Error: More materials loaded than expected. Make sure your material file names are unique (ignoring case)."); + break; + } // Load mat if (!pNewMap[cnt].Load(hGroup,entryname)) { delete [] pNewMap; return 0; }