Commit 73e6d8cd authored by Alexandre Julliard's avatar Alexandre Julliard

Fixed error handling in 16-bit functions (untested).

parent 0ad42fa7
...@@ -136,7 +136,10 @@ INT32 WINAPI LZStart32(void) ...@@ -136,7 +136,10 @@ INT32 WINAPI LZStart32(void)
*/ */
HFILE16 WINAPI LZInit16( HFILE16 hfSrc ) HFILE16 WINAPI LZInit16( HFILE16 hfSrc )
{ {
return LZInit32( FILE_GetHandle32(hfSrc) ); HFILE32 ret = LZInit32( FILE_GetHandle32(hfSrc) );
if (IS_LZ_HANDLE(ret)) return ret;
if ((INT32)ret <= 0) return ret;
return hfSrc;
} }
...@@ -449,19 +452,20 @@ LONG WINAPI LZSeek32( HFILE32 fd, LONG off, INT32 type ) ...@@ -449,19 +452,20 @@ LONG WINAPI LZSeek32( HFILE32 fd, LONG off, INT32 type )
*/ */
LONG WINAPI LZCopy16( HFILE16 src, HFILE16 dest ) LONG WINAPI LZCopy16( HFILE16 src, HFILE16 dest )
{ {
HFILE32 oldsrc = src; /* already a LZ handle? */
int usedlzinit = 0; if (IS_LZ_HANDLE(src)) return LZCopy32( src, FILE_GetHandle32(dest) );
LONG ret;
if (!IS_LZ_HANDLE(src)) /* no, try to open one */
{
src = LZInit16(src); src = LZInit16(src);
if (src!=oldsrc) usedlzinit=1; if ((INT16)src <= 0) return 0;
if (src>0xfff0) return 0; if (IS_LZ_HANDLE(src))
} {
ret = LZCopy32( src, FILE_GetHandle32(dest) ); LONG ret = LZCopy32( src, FILE_GetHandle32(dest) );
if (usedlzinit) LZClose32(src); LZClose32( src );
return ret; return ret;
}
/* it was not a compressed file */
return LZCopy32( FILE_GetHandle32(src), FILE_GetHandle32(dest) );
} }
...@@ -484,10 +488,8 @@ LONG WINAPI LZCopy32( HFILE32 src, HFILE32 dest ) ...@@ -484,10 +488,8 @@ LONG WINAPI LZCopy32( HFILE32 src, HFILE32 dest )
TRACE(file,"(%d,%d)\n",src,dest); TRACE(file,"(%d,%d)\n",src,dest);
if (!IS_LZ_HANDLE(src)) { if (!IS_LZ_HANDLE(src)) {
src = LZInit32(src); src = LZInit32(src);
if (src!=oldsrc) if ((INT32)src <= 0) return 0;
usedlzinit=1; if (src != oldsrc) usedlzinit=1;
if (src>0xfff0)
return 0;
} }
/* not compressed? just copy */ /* not compressed? just copy */
...@@ -540,12 +542,10 @@ static LPSTR LZEXPAND_MangleName( LPCSTR fn ) ...@@ -540,12 +542,10 @@ static LPSTR LZEXPAND_MangleName( LPCSTR fn )
*/ */
HFILE16 WINAPI LZOpenFile16( LPCSTR fn, LPOFSTRUCT ofs, UINT16 mode ) HFILE16 WINAPI LZOpenFile16( LPCSTR fn, LPOFSTRUCT ofs, UINT16 mode )
{ {
HFILE32 hfret; HFILE32 hfret = LZOpenFile32A( fn, ofs, mode );
hfret = LZOpenFile32A( fn, ofs, mode );
/* return errors and LZ handles unmodified */ /* return errors and LZ handles unmodified */
if (IS_LZ_HANDLE(hfret) || (hfret>=0xfff0) || (hfret<=0)) if ((INT32)hfret <= 0) return hfret;
return hfret; if (IS_LZ_HANDLE(hfret)) return hfret;
/* but allocate a dos handle for 'normal' files */ /* but allocate a dos handle for 'normal' files */
return FILE_AllocDosHandle(hfret); return FILE_AllocDosHandle(hfret);
} }
...@@ -574,8 +574,7 @@ HFILE32 WINAPI LZOpenFile32A( LPCSTR fn, LPOFSTRUCT ofs, UINT32 mode ) ...@@ -574,8 +574,7 @@ HFILE32 WINAPI LZOpenFile32A( LPCSTR fn, LPOFSTRUCT ofs, UINT32 mode )
if (fd==HFILE_ERROR32) if (fd==HFILE_ERROR32)
return HFILE_ERROR32; return HFILE_ERROR32;
cfd=LZInit32(fd); cfd=LZInit32(fd);
if (cfd<=0) if ((INT32)cfd <= 0) return fd;
return fd;
return cfd; return cfd;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment