winhelp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this patch fixes a crash while loading some .hlp files (for the curious,
when the phrase index wasn't compressed for files of version >= 4.0)

A+
Name:          wh_dec
ChangeLog:     fixed loading HCW 4.0 files without phrase image compression
License:       X11
GenDate:       2002/11/09 18:20:56 UTC
ModifiedFiles: programs/winhelp/hlpfile.c
AddedFiles:    
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winhelp/hlpfile.c,v
retrieving revision 1.11
diff -u -u -r1.11 hlpfile.c
--- programs/winhelp/hlpfile.c	21 Oct 2002 18:20:05 -0000	1.11
+++ programs/winhelp/hlpfile.c	9 Nov 2002 17:34:50 -0000
@@ -1321,7 +1321,7 @@
  */
 static BOOL HLPFILE_Uncompress_Phrases40(HLPFILE* hlpfile)
 {
-    UINT num, dec_size;
+    UINT num, dec_size, cpr_size;
     BYTE *buf_idx, *end_idx;
     BYTE *buf_phs, *end_phs;
     short i, n;
@@ -1347,11 +1347,14 @@
                GET_USHORT(buf_idx, 9 + 26));
 
     dec_size = GET_UINT(buf_idx, 9 + 12);
-    if (dec_size != HLPFILE_UncompressedLZ77_Size(buf_phs + 9, end_phs))
+    cpr_size = GET_UINT(buf_idx, 9 + 16);
+
+    if (dec_size != cpr_size &&
+        dec_size != HLPFILE_UncompressedLZ77_Size(buf_phs + 9, end_phs))
     {
         WINE_WARN("size mismatch %u %u\n",
-                  dec_size, HLPFILE_UncompressedLZ77_Size(buf_phs, end_phs));
-        dec_size = max(dec_size, HLPFILE_UncompressedLZ77_Size(buf_phs, end_phs));
+                  dec_size, HLPFILE_UncompressedLZ77_Size(buf_phs + 9, end_phs));
+        dec_size = max(dec_size, HLPFILE_UncompressedLZ77_Size(buf_phs + 9, end_phs));
     }
 
     phrases.offsets = HeapAlloc(GetProcessHeap(), 0, sizeof(unsigned) * (num + 1));
@@ -1373,7 +1376,10 @@
     }
 #undef getbit
 
-    HLPFILE_UncompressLZ77(buf_phs + 9, end_phs, phrases.buffer);
+    if (dec_size == cpr_size)
+        memcpy(phrases.buffer, buf_phs + 9, dec_size);
+    else
+        HLPFILE_UncompressLZ77(buf_phs + 9, end_phs, phrases.buffer);
 
     hlpfile->hasPhrases = FALSE;
     return TRUE;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux