Date: Sat, 2 Feb 2008 14:28:02 +1300
From: eH To: physfs@icculus.org Subject: [physfs] lzma.c msvc, etc. patch I came across a few bugs compiling PhysFS with msvc9 - I've created a patch which seems to fix them: SzFileReadImp / SzFileSeekImp: Problem: Can't preform arithmatic on 'void *' Fix: Cast 'object' to unsigned long LZMA_enumerateFiles: Problem: There is no error handling if the directory 'dname' doesn't exist Fix: Check the return value of 'lzma_find_file()' before using it LZMA_isDirectory: Problem: return (file->item->IsDirectory) is illegal if 'file' doesn't exist Fix: Make sure 'file' isn't null before returning
This commit is contained in:
parent
f7f6c0efd0
commit
ac277daac4
|
@ -2,6 +2,7 @@
|
|||
* CHANGELOG.
|
||||
*/
|
||||
|
||||
02012008 - lzma fixes (thanks, eH!).
|
||||
01222008 - Upgraded lzma sdk, lzma.c improvements (thanks, Dennis!).
|
||||
Added zlib README, and updated LICENSE.txt.
|
||||
01212008 - Fixed HTTP header in physfshttpd.c. Fixed utf-8 to UCS-2 allocation
|
||||
|
|
|
@ -130,7 +130,7 @@ SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxReqSize,
|
|||
SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size,
|
||||
size_t *processedSize)
|
||||
{
|
||||
FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); // HACK!
|
||||
FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); // HACK!
|
||||
size_t processedSizeLoc = __PHYSFS_platformRead(s->file, buffer, 1, size);
|
||||
if (processedSize != 0)
|
||||
*processedSize = processedSizeLoc;
|
||||
|
@ -145,7 +145,7 @@ SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size,
|
|||
*/
|
||||
SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
|
||||
{
|
||||
FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); // HACK!
|
||||
FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); // HACK!
|
||||
if (__PHYSFS_platformSeek(s->file, (PHYSFS_uint64) pos))
|
||||
return SZ_OK;
|
||||
return SZE_FAIL;
|
||||
|
@ -563,8 +563,18 @@ static void LZMA_enumerateFiles(dvoid *opaque, const char *dname,
|
|||
size_t dlen = strlen(dname),
|
||||
dlen_inc = dlen + ((dlen > 0) ? 1 : 0);
|
||||
LZMAarchive *archive = (LZMAarchive *) opaque;
|
||||
LZMAfile *file = (dlen ? lzma_find_file(archive, dname) + 1 : archive->files),
|
||||
*lastFile = &archive->files[archive->db.Database.NumFiles];
|
||||
LZMAfile *file = NULL,
|
||||
*lastFile = &archive->files[archive->db.Database.NumFiles];
|
||||
if (dlen)
|
||||
{
|
||||
file = lzma_find_file(archive, dname);
|
||||
if (file != NULL) // if 'file' is NULL it should stay so, otherwise errors will not be handled
|
||||
file += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
file = archive->files;
|
||||
}
|
||||
|
||||
BAIL_IF_MACRO(file == NULL, ERR_NO_SUCH_FILE, );
|
||||
|
||||
|
@ -620,7 +630,7 @@ static int LZMA_isDirectory(dvoid *opaque, const char *name, int *fileExists)
|
|||
|
||||
*fileExists = (file != NULL);
|
||||
|
||||
return(file->item->IsDirectory);
|
||||
return(file == NULL ? 0 : file->item->IsDirectory);
|
||||
} /* LZMA_isDirectory */
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue