openbsd-ports/games/numptyphysics/patches/patch-ZipFile_cpp
sthen b977e4e00b Various patches to improve the game engine and allow all the npcomplete
levels to work. Some from Erik Hovland via the numptyphysics bug tracker,
some from David Coppa. Port diff from David Coppa (maintainer).
2009-10-22 23:07:54 +00:00

24 lines
977 B
Plaintext

$OpenBSD: patch-ZipFile_cpp,v 1.1 2009/10/22 23:07:54 sthen Exp $
--- ZipFile.cpp.orig Tue Nov 11 17:54:38 2008
+++ ZipFile.cpp Thu Oct 15 14:14:50 2009
@@ -110,16 +110,16 @@ int uncompress_int(unsigned char *dest, int *destLen,
ZipFile::ZipFile(const std::string& fn)
{
m_temp = NULL;
- m_fd=open(fn.c_str(), O_RDONLY);
+ if ( m_fd=open(fn.c_str(), O_RDONLY) == -1) throw "open failed";
struct stat stat;
- fstat(m_fd, &stat);
+ if ( fstat(m_fd, &stat) != 0 ) throw "fstat failed";
m_dataLen = stat.st_size;
// TODO - win32
m_data = (unsigned char*)mmap(NULL,m_dataLen,PROT_READ,MAP_PRIVATE, m_fd, 0);
if ( !m_data ) throw "mmap failed";
if ( *(int*)&m_data[0] != 0x04034b50 ) throw "bad zip magic";
m_eoc = (zip_eoc*)&m_data[m_dataLen-sizeof(zip_eoc)];
- m_firstcd = (zip_cd*)&m_data[m_eoc->zipeofst];
+ m_firstcd = m_eoc ? (zip_cd*)&m_data[m_eoc->zipeofst] : 0;
if ( m_eoc && m_firstcd ) {
m_entries = m_eoc->zipenum;
} else {