From 02a24109251ca6cc45d8874ff821f6a7322d1623 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 13 Aug 2021 22:47:37 +1000 Subject: [PATCH] Load .lvl with corrupted custom blocks section (Thanks icanttellyou/Smappy767) --- src/Formats.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Formats.c b/src/Formats.c index 6a5449e55..8c34dd83f 100644 --- a/src/Formats.c +++ b/src/Formats.c @@ -204,7 +204,17 @@ cc_result Lvl_Load(struct Stream* stream) { if (res == ERR_END_OF_STREAM) return 0; if (res) return res; - return section == 0xBD ? Lvl_ReadCustomBlocks(&compStream) : 0; + /* Unrecognised section type, stop reading */ + if (section != 0xBD) return 0; + + res = Lvl_ReadCustomBlocks(&compStream); + /* At least one map out there has a corrupted 0xBD section */ + if (res == ERR_END_OF_STREAM) { + Chat_AddRaw("&cEnd of stream reading .lvl custom blocks section"); + Chat_AddRaw("&c Some blocks may therefore appear incorrectly"); + res = 0; + } + return res; }