From d840f2c1145a0cda2b15d564e095362efdecefb1 Mon Sep 17 00:00:00 2001
From: Kouji Sasaki <taro-x@justsystem.co.jp>
Date: Wed, 18 May 2005 09:42:52 +0000
Subject: [PATCH] Corrected RLE decompression processing.

---
 programs/winhelp/hlpfile.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c
index 24d5d4e230c..fd7027dc016 100644
--- a/programs/winhelp/hlpfile.c
+++ b/programs/winhelp/hlpfile.c
@@ -1790,18 +1790,18 @@ static void HLPFILE_UncompressRLE(const BYTE* src, const BYTE* end, BYTE** dst,
     while (src < end)
     {
         ch = *src++;
-        if (!(ch & 0x7F)) continue;
         if (ch & 0x80)
         {
             ch &= 0x7F;
-            if ((*dst) + ch < sdst)
+            if ((*dst) + ch <= sdst)
                 memcpy(*dst, src, ch);
             src += ch;
         }
         else
         {
-            if ((*dst) + ch < sdst)
-                memset(*dst, (char)*src++, ch);
+            if ((*dst) + ch <= sdst)
+                memset(*dst, (char)*src, ch);
+            src++;
         }
         *dst += ch;
     }