From 174e429f3a8080588b992bcc3d40e4f25dcb7b21 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 22 Jul 2018 21:07:03 +1000 Subject: [PATCH] Fix C client decoding .fcm maps incorrectly --- src/Client/Bitmap.c | 2 ++ src/Client/Formats.c | 2 +- src/Client/TexturePack.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Client/Bitmap.c b/src/Client/Bitmap.c index 950b8a6f7..6525a7201 100644 --- a/src/Client/Bitmap.c +++ b/src/Client/Bitmap.c @@ -463,7 +463,9 @@ ReturnCode Bitmap_DecodePng(struct Bitmap* bmp, struct Stream* stream) { if (transparentCol <= PNG_RGB_MASK) { Png_ComputeTransparency(bmp, transparentCol); } + if (bmp->Scan0 == NULL) ErrorHandler_Fail("Invalid PNG image"); + return 0; } diff --git a/src/Client/Formats.c b/src/Client/Formats.c index e79618151..bfde146be 100644 --- a/src/Client/Formats.c +++ b/src/Client/Formats.c @@ -154,7 +154,7 @@ void Fcm_Load(struct Stream* stream) { struct LocalPlayer* p = &LocalPlayer_Instance; p->Spawn.X = Stream_ReadI32_LE(stream) / 32.0f; p->Spawn.Y = Stream_ReadI32_LE(stream) / 32.0f; - p->Spawn.Z = Stream_ReadI16_LE(stream) / 32.0f; + p->Spawn.Z = Stream_ReadI32_LE(stream) / 32.0f; p->SpawnRotY = Math_Packed2Deg(Stream_ReadU8(stream)); p->SpawnHeadX = Math_Packed2Deg(Stream_ReadU8(stream)); diff --git a/src/Client/TexturePack.c b/src/Client/TexturePack.c index e08b1b33b..43fd18f6c 100644 --- a/src/Client/TexturePack.c +++ b/src/Client/TexturePack.c @@ -166,6 +166,7 @@ ReturnCode Zip_Extract(struct ZipState* state) { if (sig != ZIP_SIG_LOCALFILEHEADER) return ZIP_ERR_INVALID_LOCAL_DIR; Zip_ReadLocalFileHeader(state, entry); } + return 0; }