pts / sam2p

raster (bitmap) image converter with smart PDF and PostScript (EPS) output
http://pts.50.hu/sam2p/
GNU General Public License v2.0
42 stars 16 forks source link

Null pointor reference in function AddExtensionBlock() in cgif.c #36

Closed Xin-Jiang closed 6 years ago

Xin-Jiang commented 6 years ago

Here is the bug: 463 int CGIFFF AddExtensionBlock(CGIFFF SavedImage New, int Len, CGIFFF GifByteType ExtData[]) 464 { 465 ExtensionBlock ep; 466 467 if (New->ExtensionBlocks == NULL) 468 New->ExtensionBlocks = (ExtensionBlock *)malloc(sizeof(ExtensionBlock));

the element "New" should be checked befored used.

The crash is as follows:

(gdb) run crash000001 1.pdf

Program received signal SIGSEGV, Segmentation fault. CGIF::AddExtensionBlock (New=New@entry=0x0, Len=29, ExtData=0x691f49 "") at cgif.c:467 467 if (New->ExtensionBlocks == NULL) (gdb) bt

0 CGIF::AddExtensionBlock (New=New@entry=0x0, Len=29, ExtData=0x691f49 "") at cgif.c:467

1 0x0000000000413669 in CGIF::DGifSlurp (GifFile=GifFile@entry=0x691740) at cgif.c:1549

2 0x000000000041391d in in_gif_reader (ufd=) at in_gif.cpp:48

3 0x000000000042fca8 in Image::load (ufd0=0x66a010, loadHints=..., format=format@entry=0x0) at image.cpp:1428

4 0x0000000000401eb0 in run_sam2p_engine (sout=..., serr=..., argv1=, helpp=helpp@entry=false) at sam2p_main.cpp:1055

5 0x00000000004014d0 in main (argv=0x7fffffffe5c8) at sam2p_main.cpp:1148

(gdb) p New $1 = (CGIF::SavedImage *) 0x0 (gdb)

pts commented 6 years ago

Thank you for reporting this! Fixed in d1967482fb7920cb082dc58f0515dcdf8242df79.