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
which will stack allocate small (128 or less bytes) blocks and Malloc the
rest...naturally these now have to be paired with __PHYSFS_smallFree() calls,
so you can't be as lazy as a basic alloca() would let you be. The benefit is
both less malloc pressure for those temporary allocations and better stack
overflow safety (so if some jerk tries to push a 78 megabyte string through
the library as a filename, we won't try to strcpy it to the stack).