PNG images crash wxCocoa on OS 10.5 & 10.6 if wxCocoa built on OS 10.7 or later
|Reported by:||charliefenton||Owned by:||SC|
|Keywords:||PNG crash zlib||Cc:|
If you build wxCocoa on OS 10.8 or OS 10.9 and then run the built application on OS 10.5 or OS 10.6, it will crash when loading or processing a PNG image, even if wxCocoa was built with the OS X Deployment target set to OS X 10.5 or 10.6 (-DMAC_OS_X_VERSION_MAX_ALLOWED=1050).
The problem stems from the fact that line 31 of wxWidgets-3.0.0/src/png/pngstruct.h has:
and gets the value of ZLIB_VERNUM from that header file. But zlib is not in the OSX SDK, so zlib.h is brought in from the version of zlib provided with OS 10.7, 10.8 or OS 10.9, which have zlib 1.2.5:
#define ZLIB_VERNUM 0x1250
while OS 10.5 and OS 10.6 have zlib 1.2.3:
#define ZLIB_VERNUM 0x1230
The crash occurs in wxWidgets-3.0.0/src/png/pngrutil.c lines 381 - 307, which call inflateReset2() or inflateInit2() if ZLIB_VERNUM is at least 1240 (zlib 1.2.4). Since zlib 1.2.3 does not have these functions, the application crashes.
My suggested fix is to add the source files and headers in wxWidgets-3.0.0/src/zlib to the wxCocoa.xcodeproj, and to add wxWidgets-3.0.0/src/zlib to the project's header search path, so that the pnglib will be linked with them instead of the zlib provided by OS X. (The zlib sources in wxWidgets are version 1.2.8 and so are newer than those provided with OS 10.9.)
This bug probably applies to wxCarbon as well as wxCocoa, but I haven't tested that.
Change History (11)
comment:7 Changed 3 months ago by SC
- Owner set to SC
- Resolution set to fixed
- Status changed from new to closed
comment:8 Changed 7 weeks ago by charliefenton
- Resolution fixed deleted
- Status changed from closed to reopened
comment:9 Changed 6 weeks ago by neis
- Resolution set to port to stable
- Status changed from reopened to portneeded