sgreader icon indicating copy to clipboard operation
sgreader copied to clipboard

Crash [Mac OS X]

Open zaitsevyan opened this issue 11 years ago • 4 comments

Hi, I am trying to extract images from Empreror's files, but application crashes: Log: http://pastebin.com/BAdWVJfW

sg3: https://www.dropbox.com/s/l6ariapqfuh4uej/SprAmbient.sg3 .555: https://www.dropbox.com/s/jjtzmpe3xo74qp9/SprAmbient.555 image # 3305

zaitsevyan avatar Jun 05 '14 21:06 zaitsevyan

Got the same issue with Pharaoh files. Seems the problem comes from a unchecked return value at https://github.com/lclarkmichalek/sgreader/blob/libsg/src/gui/extractthread.cpp#L90 (According to lib code, sg_load_image_data can return NULL). I added if (sgData == NULL) {continue ;} between line 91-92 and the program exited without errors. (but seems the malloc at https://github.com/lclarkmichalek/libsg/blob/master/c/sgimage.c#L277 is not safe: invalid read/write in memory)

ccyrillee avatar Feb 13 '17 00:02 ccyrillee

Looks like there are quite a few issues there, and at least one memory leak. I don't have Emperor or Pharaoh, but I can try and fix up the obvious issues and see if that helps

lclarkmichalek avatar Feb 13 '17 08:02 lclarkmichalek

Strange sg3 file. Bitmap section looks fine, but image seems odd. At offset 11880 (680 header + 200 bitmap * 56) it's just nulls until 40752. Pecunia's reverse engineering says that we should expect one null image record after the bitmap section, but I've not seen that range of non nulls before.

lclarkmichalek avatar Jul 05 '17 21:07 lclarkmichalek

Scratch that, it's actually 680 + 200 * 200, as this isn't 0xd3, which has max 100 bitmaps

lclarkmichalek avatar Jul 05 '17 22:07 lclarkmichalek