From 10708f7a8d267ffaa89d739d42686fe12d26e92c Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 26 May 2014 18:13:38 +0200 Subject: BLADERUNNER: Fix invalid read Conditions are evaluated left to right. If you want short- circuiting to protect from invalid read, you have to do the range checks before the pointer dereferencing. --- engines/bladerunner/decompress_lcw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/bladerunner/decompress_lcw.cpp') diff --git a/engines/bladerunner/decompress_lcw.cpp b/engines/bladerunner/decompress_lcw.cpp index 15e28bf3af..8d20e231c7 100644 --- a/engines/bladerunner/decompress_lcw.cpp +++ b/engines/bladerunner/decompress_lcw.cpp @@ -40,7 +40,7 @@ uint32 decompress_lcw(uint8 *inBuf, uint32 inLen, uint8 *outBuf, uint32 outLen) ++src; } - while (src[0] != 0x80 && src < inBuf + inLen && dst < outEnd) + while (src < inBuf + inLen && dst < outEnd && src[0] != 0x80) { out_remain = (int)(outEnd - dst); -- cgit v1.2.3