[RESENDv2] winhelp: fix LZ77 decompressor
HolyLich
lich at math.spbu.ru
Thu Aug 10 05:21:20 CDT 2006
Hi,
This patch fixes a bug in LZ77 decompressor which affected only large (>0x1000)
compressed embedded files, e.g. images (metafiles). I've never noticed it corrupting
small images, but it may.
I sent this patch before but messed with MIME. Now it's OK.
ChangeLog:
winhelp: Fix LZ77 decompressor
-------------- next part --------------
Index: programs/winhelp/hlpfile.c
===================================================================
RCS file: /home/wine/wine/programs/winhelp/hlpfile.c,v
retrieving revision 1.29
diff -u -p -r1.29 hlpfile.c
--- programs/winhelp/hlpfile.c 23 May 2006 12:49:31 -0000 1.29
+++ programs/winhelp/hlpfile.c 10 Aug 2006 10:05:47 -0000
@@ -1498,8 +1498,17 @@ static BYTE *HLPFILE_UncompressLZ77(BYTE
int code = GET_USHORT(ptr, 0);
int len = 3 + (code >> 12);
int offset = code & 0xfff;
- memcpy(newptr, newptr - offset - 1, len);
- newptr += len;
+ /*
+ * We must copy byte-by-byte here. We cannot use memcpy here -
+ * areas are overlaps, so it's behaviour is unpredictable
+ * (memcpy DOES NOT copy byte-by-byte because of some
+ * optimizations).
+ * bcopy also fails, it behaves like memmove, non memcpy.
+ *
+ * WINE versions of memcpy/memmove cannot be used by the
+ * same reasons.
+ */
+ for (; len>0; len--, newptr++) *newptr = *(newptr-offset-1);
ptr += 2;
}
else *newptr++ = *ptr++;
More information about the wine-patches
mailing list