Code Monkey home page Code Monkey logo

flexpaper / pdf2json Goto Github PK

View Code? Open in Web Editor NEW
297.0 297.0 52.0 6.7 MB

PDF2JSON is a conversion library based on XPDF (3.02) which can be used for high performance PDF page by page conversion to JSON and XML format. It also supports compressing data to minimize size. PDF2JSON is available for Windows, OSX and Linux. Please see https://flowpaper.com for more information

Makefile 0.43% C 34.34% C++ 63.85% Objective-C 1.08% M4 0.06% DIGITAL Command Language 0.14% Batchfile 0.10%

pdf2json's Introduction

flexpaper

FlexPaper Flex SDK. This project provides a light weight document viewer component enabling PDF files to be viewed without having any PDF reader software installed. This project provides both Flex library and stand-alone web version. This project has changed its name from FlexPaper to FlowPaper.

License

GNU GPL v3


pdf2json's People

Contributors

flexpaper avatar futureweb avatar zmughal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdf2json's Issues

Floating point exception on DCTStream::decodeImage

Hi,

Our fuzzer found a bug due to a floating point exception on the function DCTStream::decodeImage (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_fpe_DCTStream::decodeImage

Valgrind says:

valgrind pdf2json $PoC /dev/null
==3166== Memcheck, a memory error detector
==3166== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==3166== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==3166== Command: ./pdf2json ./PoC_fpe_DCTStream::decodeImage /dev/null
==3166== 
Error (13268): Command token too long
Error (13372): Illegal character '>'
Error: PDF file is damaged - attempting to reconstruct xref table...
Error: End of file inside array
Error: End of file inside dictionary
Error (154): Dictionary key must be a name object
Error (165): Dictionary key must be a name object
Error (528): Dictionary key must be a name object
Error (530): Dictionary key must be a name object
Error (532): Dictionary key must be a name object
Error (536): Dictionary key must be a name object
Error (539): Dictionary key must be a name object
Error (545): Dictionary key must be a name object
Error (7892): Missing 'endstream'
Error (12313): Bad DCT data: missing 00 after ff
Error (12887): Bad DCT header
==3166== 
==3166== Process terminating with default action of signal 8 (SIGFPE)
==3166==  Integer divide by zero at address 0x802EBDD05
==3166==    at 0x43533F: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==3166==    by 0x40269A: main (pdf2json.cc:275)
==3166== 
==3166== HEAP SUMMARY:
==3166==     in use at exit: 263,639 bytes in 1,768 blocks
==3166==   total heap usage: 1,973 allocs, 205 frees, 355,024 bytes allocated
==3166== 
==3166== LEAK SUMMARY:
==3166==    definitely lost: 16 bytes in 1 blocks
==3166==    indirectly lost: 8 bytes in 1 blocks
==3166==      possibly lost: 0 bytes in 0 blocks
==3166==    still reachable: 263,615 bytes in 1,766 blocks
==3166==         suppressed: 0 bytes in 0 blocks
==3166== Rerun with --leak-check=full to see details of leaked memory
==3166== 
==3166== For counts of detected and suppressed errors, rerun with: -v
==3166== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Floating point exception

Thanks,
Manh Dung

Problem with content in one line being seperated to multiple ones

Hi guys,

I am trying to find signatures in a document by checking each line and seeing if it has the code signature however when doing that I noticed it splits content which is in the same into multiple lines for some reason, how can I tackle this?

2020-07-17T09:55:54.404Z	adfcfc04-637c-4228-b256-6a5b3214308c	INFO	Signed%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6.
2020-07-17T09:55:54.404Z	adfcfc04-637c-4228-b256-6a5b3214308c	INFO	SIGN_ABOVE_HERE
2020-07-17T09:55:54.423Z	adfcfc04-637c-4228-b256-6a5b3214308c	INFO	_
2020-07-17T09:55:54.423Z	adfcfc04-637c-4228-b256-6a5b3214308c	INFO	JOHN
2020-07-17T09:55:54.423Z	adfcfc04-637c-4228-b256-6a5b3214308c	INFO	_
2020-07-17T09:55:54.423Z	adfcfc04-637c-4228-b256-6a5b3214308c	INFO	Signed%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6%E2%80%A6.
2020-07-17T09:55:54.423Z	adfcfc04-637c-4228-b256-6a5b3214308c	INFO	SIGN
2020-07-17T09:55:54.423Z	adfcfc04-637c-4228-b256-6a5b3214308c	INFO	_ABOVE_HERE_SUSAN_

I am attaching a doc so u can see how it looks like too
doc.docx

SEGV on GfxState::~GfxState

Hi,

Our fuzzer found a crash due to an invalid read on the function GfxState::~GfxState (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_segv_GfxState::~GfxState

Valgrind says:

valgrind pdf2json $PoC /dev/null
==7805== Invalid read of size 8
==7805==    at 0x41ACF7: GfxState::~GfxState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==7805==    by 0x41C839: GfxState::restore() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==7805==    by 0x467BEB: Gfx::restoreState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==7805==    by 0x42A5AA: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==7805==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==7805==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==7805==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==7805==    by 0x40269A: main (pdf2json.cc:275)
==7805==  Address 0xbdcabdbebdbcbdb0 is not stack'd, malloc'd or (recently) free'd
Segmentation fault

Thanks,
Manh Dung

SEGV (invalid write) on JBIG2Bitmap::clearToZero

Hi,

Our fuzzer found a crash due to an invalid write on the function JBIG2Bitmap::clearToZero (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_segv_JBIG2Bitmap::clearToZero

Valgrind says:

valgrind pdf2json $PoC /dev/null
==4874== Invalid write of size 8
==4874==    at 0x4C3453F: memset (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4874==    by 0x470452: JBIG2Bitmap::clearToZero() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x477FE3: JBIG2Stream::readGenericRefinementRegion(int, int, int, int, JBIG2Bitmap*, int, int, int*, int*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x474F79: JBIG2Stream::readTextRegion(int, int, int, int, unsigned int, unsigned int, int, JBIG2HuffmanTable*, unsigned int, JBIG2Bitmap**, unsigned int, unsigned int, unsigned int, unsigned int, int, JBIG2HuffmanTable*, JBIG2HuffmanTable*, JBIG2HuffmanTable*, JBIG2HuffmanTable*, JBIG2HuffmanTable*, JBIG2HuffmanTable*, JBIG2HuffmanTable*, JBIG2HuffmanTable*, unsigned int, int*, int*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x4730FC: JBIG2Stream::readSymbolDictSeg(unsigned int, unsigned int, unsigned int*, unsigned int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x471EF0: JBIG2Stream::readSegments() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x4718BF: JBIG2Stream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==4874==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Thanks,
Manh Dung

SEGV (invalid write) on JBIG2Stream::readSymbolDictSeg

Hi,

Our fuzzer found a crash due to an invalid write on the function JBIG2Stream::readSymbolDictSeg (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_segv_JBIG2Stream::readSymbolDictSeg

Valgrind says:

valgrind pdf2json $PoC /dev/null
==549== Invalid write of size 8
==549==    at 0x473170: JBIG2Stream::readSymbolDictSeg(unsigned int, unsigned int, unsigned int*, unsigned int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x471EF0: JBIG2Stream::readSegments() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x4718BF: JBIG2Stream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x40269A: main (pdf2json.cc:275)
==549==  Address 0x5b550d8 is 0 bytes after a block of size 264 alloc'd
==549==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==549==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x472780: JBIG2Stream::readSymbolDictSeg(unsigned int, unsigned int, unsigned int*, unsigned int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x471EF0: JBIG2Stream::readSegments() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x4718BF: JBIG2Stream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==549==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)

Thanks,
Manh Dung

SEGV (NULL pointer dereference) on EmbedStream::getChar

Hi,

Our fuzzer found a crash due to a NULL pointer dereference bug on the function EmbedStream::getChar (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_npd_EmbedStream::getChar

Valgrind says:

valgrind pdf2json $PoC /dev/null
==23888== Memcheck, a memory error detector
==23888== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==23888== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==23888== Command: ./pdf2json ./PoC_npd_EmbedStream::getChar /dev/null
==23888== 
Error: May not be a PDF file (continuing anyway)
Error: PDF file is damaged - attempting to reconstruct xref table...
Error (15671): Dictionary key must be a name object
Error (15674): Dictionary key must be a name object
Error (1930): Dictionary key must be a name object
Error (1933): Dictionary key must be a name object
Error (1935): Dictionary key must be a name object
Error (1937): Dictionary key must be a name object
Error (1940): Dictionary key must be a name object
Error (3436): Illegal character ')'
Error: Unterminated string
Error: Bad image parameters
==23888== Invalid read of size 8
==23888==    at 0x42ECFA: EmbedStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x466405: Gfx::opBeginImage(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x40269A: main (pdf2json.cc:275)
==23888==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==23888== 
==23888== 
==23888== Process terminating with default action of signal 11 (SIGSEGV)
==23888==  Access not within mapped region at address 0x0
==23888==    at 0x42ECFA: EmbedStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x466405: Gfx::opBeginImage(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23888==    by 0x40269A: main (pdf2json.cc:275)
==23888==  If you believe this happened as a result of a stack
==23888==  overflow in your program's main thread (unlikely but
==23888==  possible), you can try to increase the size of the
==23888==  main thread stack using the --main-stacksize= flag.
==23888==  The main thread stack size used in this run was 8388608.
==23888== 
==23888== HEAP SUMMARY:
==23888==     in use at exit: 212,135 bytes in 1,754 blocks
==23888==   total heap usage: 1,929 allocs, 175 frees, 301,634 bytes allocated
==23888== 
==23888== LEAK SUMMARY:
==23888==    definitely lost: 16 bytes in 1 blocks
==23888==    indirectly lost: 8 bytes in 1 blocks
==23888==      possibly lost: 0 bytes in 0 blocks
==23888==    still reachable: 212,111 bytes in 1,752 blocks
==23888==         suppressed: 0 bytes in 0 blocks
==23888== Rerun with --leak-check=full to see details of leaked memory
==23888== 
==23888== For counts of detected and suppressed errors, rerun with: -v
==23888== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

SEGV (stack overflow) on vfprintf

Hi,

Our fuzzer found a crash due to a stack overflow bug on the function vfprintf (the latest commit b671b64 on master - version 0.70).

PoC_so_vfprintf: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_so_vfprintf

Valgrind says:

valgrind pdf2json PoC_so_vfprintf /dev/null
==8530== Memcheck, a memory error detector
==8530== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==8530== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==8530== Command: ./pdf2json PoC_so_vfprintf /dev/null
==8530== 
Error: PDF file is damaged - attempting to reconstruct xref table...
Error (13719): Illegal character <8e> in hex string
Error (13778): Illegal character <db> in hex string
Error (13781): Illegal character <94> in hex string
Error (13782): Illegal character <02> in hex string
Error (13783): Illegal character <a2> in hex string
Error: End of file inside array
Error: End of file inside dictionary
Error (193): Illegal character '>'
Error (195): Dictionary key must be a name object
Error (203): Dictionary key must be a name object
Error (229): Dictionary key must be a name object
Error (232): Dictionary key must be a name object
Error (491): Illegal character <01> in hex string
Error (496): Illegal character <6e> in hex string
Error (498): Illegal character <6f> in hex string
Error (500): Illegal character <6a> in hex string
Error (506): Illegal character <6f> in hex string
Error (508): Illegal character <6a> in hex string
Error (510): Illegal character <3c> in hex string
Error (511): Illegal character <3c> in hex string
Error (513): Illegal character <2f> in hex string
...
Error (8023): Dictionary key must be a name object
==8530== Stack overflow in thread #1: can't grow stack to 0xffe801000
==8530== 
==8530== Process terminating with default action of signal 11 (SIGSEGV)
==8530==  Access not within mapped region at address 0xFFE801FF8
==8530== Stack overflow in thread #1: can't grow stack to 0xffe801000
==8530==    at 0x5756642: _IO_default_xsputn (genops.c:422)
==8530==  If you believe this happened as a result of a stack
==8530==  overflow in your program's main thread (unlikely but
==8530==  possible), you can try to increase the size of the
==8530==  main thread stack using the --main-stacksize= flag.
==8530==  The main thread stack size used in this run was 8388608.
==8530== Stack overflow in thread #1: can't grow stack to 0xffe801000
==8530== 
==8530== Process terminating with default action of signal 11 (SIGSEGV)
==8530==  Access not within mapped region at address 0xFFE801FF0
==8530== Stack overflow in thread #1: can't grow stack to 0xffe801000
==8530==    at 0x4A28680: _vgnU_freeres (in /usr/lib/valgrind/vgpreload_core-amd64-linux.so)
==8530==  If you believe this happened as a result of a stack
==8530==  overflow in your program's main thread (unlikely but
==8530==  possible), you can try to increase the size of the
==8530==  main thread stack using the --main-stacksize= flag.
==8530==  The main thread stack size used in this run was 8388608.
==8530== 
==8530== HEAP SUMMARY:
==8530==     in use at exit: 15,497,401 bytes in 256,831 blocks
==8530==   total heap usage: 435,600 allocs, 178,769 frees, 16,602,462 bytes allocated
==8530== 
==8530== LEAK SUMMARY:
==8530==    definitely lost: 0 bytes in 0 blocks
==8530==    indirectly lost: 0 bytes in 0 blocks
==8530==      possibly lost: 0 bytes in 0 blocks
==8530==    still reachable: 15,497,401 bytes in 256,831 blocks
==8530==         suppressed: 0 bytes in 0 blocks
==8530== Rerun with --leak-check=full to see details of leaked memory
==8530== 
==8530== For counts of detected and suppressed errors, rerun with: -v
==8530== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

SEGV on ObjectStream::getObject

Hi,

Our fuzzer found a crash due to an invalid read on the function ObjectStream::getObject (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_segv_ObjectStream::getObject

Valgrind says

valgrind pdf2json $PoC /dev/null
==440== Memcheck, a memory error detector
==440== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==440== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==440== Command: ./pdf2json ./PoC_segv_ObjectStream::getObject /dev/null
==440== 
==440== Invalid read of size 4
==440==    at 0x43D665: ObjectStream::getObject(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x43FB45: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x4094D9: XRef::getCatalog(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x407B94: Catalog::Catalog(XRef*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x42B5FA: PDFDoc::setup(GString*, GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x42B3B4: PDFDoc::PDFDoc(GString*, GString*, GString*, void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x402163: main (pdf2json.cc:159)
==440==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
==440== 
==440== 
==440== Process terminating with default action of signal 11 (SIGSEGV)
==440==  Access not within mapped region at address 0x10
==440==    at 0x43D665: ObjectStream::getObject(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x43FB45: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x4094D9: XRef::getCatalog(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x407B94: Catalog::Catalog(XRef*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x42B5FA: PDFDoc::setup(GString*, GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x42B3B4: PDFDoc::PDFDoc(GString*, GString*, GString*, void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==440==    by 0x402163: main (pdf2json.cc:159)
==440==  If you believe this happened as a result of a stack
==440==  overflow in your program's main thread (unlikely but
==440==  possible), you can try to increase the size of the
==440==  main thread stack using the --main-stacksize= flag.
==440==  The main thread stack size used in this run was 8388608.
==440== 
==440== HEAP SUMMARY:
==440==     in use at exit: 204,239 bytes in 1,701 blocks
==440==   total heap usage: 1,792 allocs, 91 frees, 353,981 bytes allocated
==440== 
==440== LEAK SUMMARY:
==440==    definitely lost: 0 bytes in 0 blocks
==440==    indirectly lost: 0 bytes in 0 blocks
==440==      possibly lost: 0 bytes in 0 blocks
==440==    still reachable: 204,239 bytes in 1,701 blocks
==440==         suppressed: 0 bytes in 0 blocks
==440== Rerun with --leak-check=full to see details of leaked memory
==440== 
==440== For counts of detected and suppressed errors, rerun with: -v
==440== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

Detected memory leaks

I use Clang 6.0 and AddressSanitizer to build pdf2json v0.69, this file can cause memory leaks with the following command:

./pdf2json detected_memory_leaks.pdf 1.json

This is the ASAN information:

=================================================================
==15578==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x516e58 in operator new(unsigned long) /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:92
    #1 0x5e9bcf in GString::copy() /home/fouzhe/my_fuzz/pdf2json/xpdf/./../goo/GString.h:41:28
    #2 0x5e9bcf in GlobalParams::getTextEncodingName() /home/fouzhe/my_fuzz/pdf2json/xpdf/GlobalParams.cc:2256

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x516e58 in operator new(unsigned long) /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:92
    #1 0x6094f1 in Page::getLinks(Catalog*) /home/fouzhe/my_fuzz/pdf2json/xpdf/Page.cc:254:11
    #2 0x60fe2e in PDFDoc::getLinks(int) /home/fouzhe/my_fuzz/pdf2json/xpdf/PDFDoc.cc:351:34
    #3 0x60fe2e in PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/PDFDoc.cc:320
    #4 0x60fe2e in PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/PDFDoc.cc:332

Indirect leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x517008 in operator new[](unsigned long) /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:95
    #1 0x8cc5ce in GString::resize(int) /home/fouzhe/my_fuzz/pdf2json/goo/GString.cc:87:9
    #2 0x8cc5ce in GString::GString(GString*) /home/fouzhe/my_fuzz/pdf2json/goo/GString.cc:131

SUMMARY: AddressSanitizer: 40 byte(s) leaked in 3 allocation(s).

Passages with spaces joined by periods rather than split into separate words

We have noticed an issue where in somes cases pieces of our text are joined by periods into one massive word, rather than split by spaces into individual array members, eg:

[1027,54,538,27,38,"Churches.set.up.Christian.schools.in.the.early.1800s..Some.Indigenous.peoples.were."]

Not sure if you have any idea what might cause this – if it’s an issue in our PDFs or something that pdf2json is getting wrong for some reason?

Stack-buffer-overflow-XRef-fetch

$ ./pdf2json 01-Stack-buffer-overflow-XRef-fetch.pdf
ASAN:SIGSEGV
=================================================================
==89368==ERROR: AddressSanitizer: stack-overflow on address 0x7ffc9d6bcfe0 (pc 0x7f2cf5cba26e bp 0x000000000018 sp 0x7ffc9d6bcfd0 T0)
    #0 0x7f2cf5cba26d  (/usr/lib/x86_64-linux-gnu/libasan.so.2+0xb026d)
    #1 0x7f2cf5cb9d67  (/usr/lib/x86_64-linux-gnu/libasan.so.2+0xafd67)
    #2 0x7f2cf5c2cf4f  (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x22f4f)
    #3 0x7f2cf5ca34fe in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x994fe)
    #4 0x4345c4 in XRef::fetch(int, int, Object*) /home/test/pdf2json_tmp/xpdf/XRef.cc:839
    #5 0x434835 in ObjectStream::ObjectStream(XRef*, int) /home/test/pdf2json_tmp/xpdf/XRef.cc:84
    #6 0x4345d6 in XRef::fetch(int, int, Object*) /home/test/pdf2json_tmp/xpdf/XRef.cc:839
    #7 0x434835 in ObjectStream::ObjectStream(XRef*, int) /home/test/pdf2json_tmp/xpdf/XRef.cc:84
    #8 0x4345d6 in XRef::fetch(int, int, Object*) /home/test/pdf2json_tmp/xpdf/XRef.cc:839
    #9 0x434835 in ObjectStream::ObjectStream(XRef*, int) /home/test/pdf2json_tmp/xpdf/XRef.cc:84
    #10 0x4345d6 in XRef::fetch(int, int, Object*) /home/test/pdf2json_tmp/xpdf/XRef.cc:839
    #11 0x434835 in ObjectStream::ObjectStream(XRef*, int) /home/test/pdf2json_tmp/xpdf/XRef.cc:84

ref:https://github.com/Aurorainfinity/Poc/tree/master/pdf2json
01-Stack-buffer-overflow-XRef-fetch.pdf

NULL-pointer-dereference-ObjectStream-getObject

$  ./pdf2json 00-NULL-pointer-dereference-ObjectStream-getObject.pdf
Error (1853): Dictionary key must be a name object
Error (1860): Dictionary key must be a name object
ASAN:SIGSEGV
=================================================================
==88712==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000432f60 bp 0x7ffe1f9cf650 sp 0x7ffe1f9cf5b8 T0)
    #0 0x432f5f in ObjectStream::getObject(int, int, Object*) /home/test/pdf2json_tmp/xpdf/XRef.cc:183
    #1 0x4345ec in XRef::fetch(int, int, Object*) /home/test/pdf2json_tmp/xpdf/XRef.cc:841
    #2 0x411283 in Object::dictLookup(char*, Object*) /home/test/pdf2json_tmp/xpdf/Object.h:253
    #3 0x411283 in Catalog::Catalog(XRef*) /home/test/pdf2json_tmp/xpdf/Catalog.cc:51
    #4 0x427fe0 in PDFDoc::setup(GString*, GString*) /home/test/pdf2json_tmp/xpdf/PDFDoc.cc:201
    #5 0x42815b in PDFDoc::PDFDoc(GString*, GString*, GString*, void*) /home/test/pdf2json_tmp/xpdf/PDFDoc.cc:101
    #6 0x402856 in main /home/test/pdf2json_tmp/src/pdf2json.cc:159
    #7 0x7fd2eaec383f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #8 0x403788 in _start (/home/test/pdf2json_tmp/src/pdf2json+0x403788)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/test/pdf2json_tmp/xpdf/XRef.cc:183 ObjectStream::getObject(int, int, Object*)
==88712==ABORTING

ref:https://github.com/Aurorainfinity/Poc/tree/master/pdf2json
00-NULL-pointer-dereference-ObjectStream-getObject.pdf

Version 1.3.1 stipulates unworkable "supported engine"

The latest 1.3.1 version of pdf2json shows this when I update:

npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=14.18.0","npm":">=6.14.15"} (current: {"node":"14.18.1","npm":"6.14.12"}) 
npm WARN notsup Not compatible with your version of node/npm: [email protected]

My version of node is supported, but the version of npm requires something newer than that version of node installs. That would mean, in order to use this library in a build process (like a Jenkins pipeline or container), I would need to install not only a specific image including node 14 (14.18.1 is newest available release) but also update npm separately to a newer version than what is supplied by that binary (6.14.12).

Invalid read on DCTStream::readHuffSym

Hi,

Our fuzzer found a bug due to an invalid read on the function DCTStream::readHuffSym (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_ir_DCTStream::readHuffSym

Valgrind says:

valgrind pdf2json $PoC /dev/null
==8920== Memcheck, a memory error detector
==8920== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==8920== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==8920== Command: ./pdf2json ./PoC_ir_DCTStream::readHuffSym /dev/null
==8920== 
Error: PDF file is damaged - attempting to reconstruct xref table...
Error (17141): Illegal character <5c> in hex string
Error (17152): Illegal character <78> in hex string
Error (105): Dictionary key must be a name object
Error (154): Dictionary key must be a name object
Error (165): Dictionary key must be a name object
Error (528): Dictionary key must be a name object
Error (530): Dictionary key must be a name object
Error (532): Dictionary key must be a name object
Error (536): Dictionary key must be a name object
Error (539): Dictionary key must be a name object
Error (545): Dictionary key must be a name object
Error (8015): Command token too long
Error (8143): Command token too long
Error (8143): Missing 'endstream'
==8920== Invalid read of size 2
==8920==    at 0x436A05: DCTStream::readHuffSym(DCTHuffTable*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x434C67: DCTStream::readProgressiveDataUnit(DCTHuffTable*, DCTHuffTable*, int*, int*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x434765: DCTStream::readScan() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x432C49: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x40269A: main (pdf2json.cc:275)
==8920==  Address 0x5b124e2 is 2 bytes after a block of size 32 alloc'd
==8920==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8920==    by 0x4877C8: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x40269A: main (pdf2json.cc:275)
==8920== 
==8920== Invalid read of size 2
==8920==    at 0x436A1F: DCTStream::readHuffSym(DCTHuffTable*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x434C67: DCTStream::readProgressiveDataUnit(DCTHuffTable*, DCTHuffTable*, int*, int*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x434765: DCTStream::readScan() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x432C49: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==8920==    by 0x40269A: main (pdf2json.cc:275)
==8920==  Address 0x5b12504 is 28 bytes before a block of size 128 in arena "client"
==8920== 
Error (1759): Bad Huffman code in DCT stream
Error (12887): Bad DCT header
Error (12887): Unknown operator '������������������������������������������������������������������������������������������������'
...
==8920== 
==8920== HEAP SUMMARY:
==8920==     in use at exit: 72,744 bytes in 4 blocks
==8920==   total heap usage: 2,947 allocs, 2,943 frees, 693,136 bytes allocated
==8920== 
==8920== LEAK SUMMARY:
==8920==    definitely lost: 32 bytes in 2 blocks
==8920==    indirectly lost: 8 bytes in 1 blocks
==8920==      possibly lost: 0 bytes in 0 blocks
==8920==    still reachable: 72,704 bytes in 1 blocks
==8920==         suppressed: 0 bytes in 0 blocks
==8920== Rerun with --leak-check=full to see details of leaked memory
==8920== 
==8920== For counts of detected and suppressed errors, rerun with: -v
==8920== ERROR SUMMARY: 30 errors from 2 contexts (suppressed: 0 from 0)

Thanks,
Manh Dung

SEGV (use after free) on Gfx::doShowText

Hi,

Our fuzzer found a crash due to an Use After Free bug on the function Gfx::doShowText (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_uaf_Gfx::doShowText

Valgrind says:

valgrind pdf2json $PoC /dev/null
==22556== Memcheck, a memory error detector
==22556== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==22556== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==22556== Command: ./pdf2json ./PoC_uaf_Gfx::doShowText /dev/null
==22556== 
...
==22556== Invalid read of size 8
==22556==    at 0x462BD5: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2b040 is 0 bytes inside a block of size 4,584 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46C5E3: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x469005: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x4031FB: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:81)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2b0e0 is 160 bytes inside a block of size 4,584 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46C5E3: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x469005: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x403238: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:82)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2b0e8 is 168 bytes inside a block of size 4,584 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46C5E3: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x469005: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x40325C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:86)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2b058 is 24 bytes inside a block of size 4,584 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46C5E3: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x469005: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 4
==22556==    at 0x41CA4E: GString::getLength() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C320: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x406434: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:88)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2af50 is 0 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46947A: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x468F7E: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x409098: GString::getCString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C354: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x406434: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:88)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2af58 is 8 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46947A: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x468F7E: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x4C326C8: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C36D: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x406434: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:88)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2afa0 is 0 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F74B: operator delete[](void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C698: GString::~GString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x469472: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E80F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48E420: GString::resize(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C1C7: GString::GString(char const*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x468F8C: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 2
==22556==    at 0x4C32720: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C36D: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x406434: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:88)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2afa8 is 8 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F74B: operator delete[](void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C698: GString::~GString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x469472: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E80F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48E420: GString::resize(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C1C7: GString::GString(char const*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x468F8C: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 1
==22556==    at 0x4C32758: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C36D: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x406434: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:88)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2afac is 12 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F74B: operator delete[](void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C698: GString::~GString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x469472: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E80F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48E420: GString::resize(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C1C7: GString::GString(char const*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x468F8C: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 4
==22556==    at 0x41CA4E: GString::getLength() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C320: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x40644C: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:89)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2af50 is 0 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46947A: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x468F7E: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x409098: GString::getCString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C354: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x40644C: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:89)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2af58 is 8 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46947A: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x468F7E: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x4C326C8: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C36D: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x40644C: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:89)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2afa0 is 0 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F74B: operator delete[](void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C698: GString::~GString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x469472: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E80F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48E420: GString::resize(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C1C7: GString::GString(char const*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x468F8C: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 2
==22556==    at 0x4C32720: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C36D: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x40644C: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:89)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2afa8 is 8 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F74B: operator delete[](void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C698: GString::~GString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x469472: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E80F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48E420: GString::resize(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C1C7: GString::GString(char const*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x468F8C: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 1
==22556==    at 0x4C32758: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C36D: GString::GString(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x40644C: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:89)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2afac is 12 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F74B: operator delete[](void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C698: GString::~GString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x469472: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E80F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48E420: GString::resize(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C1C7: GString::GString(char const*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x468F8C: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x4064E9: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:106)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2af58 is 8 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46947A: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x468F7E: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 1
==22556==    at 0x577A570: __strcmp_sse2_unaligned (strcmp-sse2-unaligned.S:24)
==22556==    by 0x406516: XmlFont::XmlFont(GString*, int, double, GfxRGB) (XmlFonts.cc:110)
==22556==    by 0x40328C: HtmlString::HtmlString(GfxState*, double, double, XmlFontAccu*) (ImgOutputDev.cc:88)
==22556==    by 0x4036BE: HtmlPage::beginString(GfxState*, GString*) (ImgOutputDev.cc:237)
==22556==    by 0x462C57: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2afa0 is 0 bytes inside a block of size 16 free'd
==22556==    at 0x4C2F74B: operator delete[](void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48C698: GString::~GString() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x469472: GfxFont::~GfxFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C587: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46C5D7: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E80F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x48E420: GString::resize(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x48C1C7: GString::GString(char const*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x468F8C: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 4
==22556==    at 0x467E4E: GfxFont::getType() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x462C66: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2b068 is 40 bytes inside a block of size 4,584 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46C5E3: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x469005: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== Invalid read of size 8
==22556==    at 0x4636BD: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Address 0x5b2b040 is 0 bytes inside a block of size 4,584 free'd
==22556==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x46C5E3: Gfx8BitFont::~Gfx8BitFont() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46EEC9: GfxFontDict::~GfxFontDict() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x4534F2: GfxResources::~GfxResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467CC3: Gfx::popResources() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x466309: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==  Block was alloc'd at
==22556==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22556==    by 0x469005: GfxFont::makeFont(XRef*, char*, Ref, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46ECFB: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x453380: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x467C63: Gfx::pushResources(Dict*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465DBB: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x465CE0: Gfx::doForm(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x464230: Gfx::opXObject(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
pure virtual method called
terminate called without an active exception
==22556== 
==22556== Process terminating with default action of signal 6 (SIGABRT)
==22556==    at 0x5710428: raise (raise.c:54)
==22556==    by 0x5712029: abort (abort.c:89)
==22556==    by 0x4EC984C: __gnu_cxx::__verbose_terminate_handler() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==22556==    by 0x4EC76B5: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==22556==    by 0x4EC7700: std::terminate() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==22556==    by 0x4EC823E: __cxa_pure_virtual (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==22556==    by 0x463726: Gfx::doShowText(GString*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46243E: Gfx::opShowText(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454B1D: Gfx::execOp(Object*, Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454536: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556==    by 0x46627C: Gfx::doForm1(Object*, Dict*, double*, double*, int, int, GfxColorSpace*, int, int, int, Function*, GfxColor*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==22556== 
==22556== HEAP SUMMARY:
==22556==     in use at exit: 321,643 bytes in 2,154 blocks
==22556==   total heap usage: 6,498 allocs, 4,344 frees, 577,716 bytes allocated
==22556== 
==22556== LEAK SUMMARY:
==22556==    definitely lost: 16 bytes in 1 blocks
==22556==    indirectly lost: 8 bytes in 1 blocks
==22556==      possibly lost: 0 bytes in 0 blocks
==22556==    still reachable: 321,619 bytes in 2,152 blocks
==22556==                       of which reachable via heuristic:
==22556==                         newarray           : 264 bytes in 1 blocks
==22556==         suppressed: 0 bytes in 0 blocks
==22556== Rerun with --leak-check=full to see details of leaked memory
==22556== 
==22556== For counts of detected and suppressed errors, rerun with: -v
==22556== ERROR SUMMARY: 33 errors from 18 contexts (suppressed: 0 from 0)
Aborted

Thanks,
Manh Dung

Cant generate chinese pdf to js file

Hi
I am try to generate js file form Chinese pdf using command prompt,ii will get error like font CMap missing for Chinese

C:\Program Files (x86)\PDF2JSON>pdf2json.exe "C:\Users\Aravind\Desktop\New folder\11Apr2017103943_1.pdf" -enc UTF-8 -hidden -compress "C:\Users\Aravind\Desktop\New folder\11Apr2017103943_1.js"

Error: Couldn't find 'UniCNS-UCS2-H' CMap file for 'Adobe-CNS1' collection
Error: Unknown CMap 'UniCNS-UCS2-H' for character collection 'Adobe-CNS1'
Error: Couldn't find 'UniCNS-UCS2-H' CMap file for 'Adobe-CNS1' collection
Error: Unknown CMap 'UniCNS-UCS2-H' for character collection 'Adobe-CNS1'
Error: Couldn't find 'UniGB-UCS2-H' CMap file for 'Adobe-GB1' collection
Error: Unknown CMap 'UniGB-UCS2-H' for character collection 'Adobe-GB1'
Error: Unknown font tag 'F0'
Error (2454): No font in show
Error (2477): No font in show
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F4'
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F2'
Error: Unknown font tag 'F0'
Error: Unknown font tag 'F0'
Page-1

Anybody help for this issue, i am installed adobe reader with Asian language pack,but no luck,that Chinese PDF id already ocr'd ,when i copy content form pdf and paste into ms word,i will get what exact in pdf file.

Regards
Aravind

generate new release

Hey there,
could you generate a new Release Version with the latest pulled changes? (#12)
As current Release Version got Problems ...
thx
Andreas Schnederle-Wagner

Reversing? JSON to PDF

Is it at all possible to reverse the objective of this program: to generate a PDF from the given JSON?

Bugs in pdf2json

Hello,

I recently discovered 3 separate inputs that can cause pdf2json to crash (with different stack traces). On Windows 10, one causes a stack buffer overrun exception in pdf2json.exe, one causes the same exception in ntdll.dll, and one causes a stack overflow exception. Please find example inputs attached. Tested with the following command line:
pdf2json.exe /dev/null
inputs.zip

Segmentation fault issue

When I try to convert PDF using pdf2json inside the docker container (ubuntu:xenial), I am getting the following segmentation fault issue. This is the stack trace

Starting program: /tmp/pdf2json-0.70/src/pdf2json /data/materials_cache/ObsKPcCX1X3X2X53PlwIgjVz-d592b20cba4ac78a319491def9366467/main.pdf -enc UTF-8 -compress /data/materials_cache/ObsKPcCX1X3X2X53PlwIgjVz-d592b20cba4ac78a319491def9366467/main.js

Program received signal SIGSEGV, Segmentation fault.
0x0000000000435105 in DecryptStream::getChar (this=0x6f57f0) at Decrypt.cc:271
271           c = state.aes.buf[state.aes.bufIdx++];
(gdb) bt
#0  0x0000000000435105 in DecryptStream::getChar (this=0x6f57f0) at Decrypt.cc:271
#1  0x00000000004603ee in Parser::getObj (this=this@entry=0x6efd30, obj=obj@entry=0x7fffffffe160, 
    fileKey=fileKey@entry=0x6f024c "\004\227\243\226\035ܗ\337\274>M\371\364~Vs\020", encAlgorithm=encAlgorithm@entry=cryptAES, 
    keyLength=keyLength@entry=16, objNum=objNum@entry=1338, objGen=0) at Parser.cc:127
#2  0x0000000000460677 in Parser::getObj (this=this@entry=0x6efd30, obj=obj@entry=0x7fffffffe1f0, 
    fileKey=fileKey@entry=0x6f024c "\004\227\243\226\035ܗ\337\274>M\371\364~Vs\020", encAlgorithm=encAlgorithm@entry=cryptAES, 
    keyLength=keyLength@entry=16, objNum=objNum@entry=1338, objGen=0) at Parser.cc:85
#3  0x0000000000460677 in Parser::getObj (this=this@entry=0x6efd30, obj=obj@entry=0x7fffffffe280, 
    fileKey=fileKey@entry=0x6f024c "\004\227\243\226\035ܗ\337\274>M\371\364~Vs\020", encAlgorithm=encAlgorithm@entry=cryptAES, 
    keyLength=keyLength@entry=16, objNum=objNum@entry=1338, objGen=0) at Parser.cc:85
#4  0x0000000000460677 in Parser::getObj (this=this@entry=0x6efd30, obj=obj@entry=0x7fffffffe370, 
    fileKey=0x6f024c "\004\227\243\226\035ܗ\337\274>M\371\364~Vs\020", encAlgorithm=cryptAES, keyLength=16, objNum=objNum@entry=1338, objGen=0)
    at Parser.cc:85
#5  0x000000000042b52d in XRef::fetch (this=0x6f01e0, num=1338, gen=<optimized out>, obj=obj@entry=0x7fffffffe370) at XRef.cc:824
#6  0x0000000000407fe0 in XRef::getCatalog (obj=0x7fffffffe370, this=<optimized out>) at XRef.h:72
#7  Catalog::Catalog (this=0x6eff50, xrefA=<optimized out>) at Catalog.cc:44
#8  0x000000000041edb1 in PDFDoc::setup (this=this@entry=0x6f0190, ownerPassword=ownerPassword@entry=0x0, userPassword=userPassword@entry=0x0)
    at PDFDoc.cc:201
#9  0x000000000041ef2c in PDFDoc::PDFDoc (this=0x6f0190, fileNameA=<optimized out>, ownerPassword=0x0, userPassword=0x0, guiDataA=<optimized out>)
    at PDFDoc.cc:101
#10 0x00000000004020a4 in main (argc=3, argv=0x7fffffffe658) at pdf2json.cc:159

Alloc_dealloc_mismatch in function ~HtmlString

I use Clang 6.0 and AddressSanitizer to build pdf2json v0.69, this file can cause alloc-dealloc-mismatch with the following command:

./pdf2json alloc_dealloc_mismatch_~HtmlString.pdf 1.json

This is the ASAN information:

=================================================================
==22708==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x606000004580
    #0 0x517bd0 in operator delete(void*) /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:149
    #1 0x51c1ec in HtmlString::~HtmlString() /home/fouzhe/my_fuzz/pdf2json/src/ImgOutputDev.cc:118:3
    #2 0x52282c in HtmlPage::coalesce() /home/fouzhe/my_fuzz/pdf2json/src/ImgOutputDev.cc:558:10
    #3 0x52a41c in ImgOutputDev::endPage() /home/fouzhe/my_fuzz/pdf2json/src/ImgOutputDev.cc:978:10
    #4 0x78c975 in Gfx::~Gfx() /home/fouzhe/my_fuzz/pdf2json/xpdf/Gfx.cc:530:10
    #5 0x60aa91 in Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/Page.cc:359:3
    #6 0x609810 in Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/Page.cc:265:3
    #7 0x60feb5 in PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/PDFDoc.cc:319:27
    #8 0x60feb5 in PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/PDFDoc.cc:332
    #9 0x53c946 in main /home/fouzhe/my_fuzz/pdf2json/src/pdf2json.cc:275:10
    #10 0x7f1f071e482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #11 0x41b198 in _start (/home/fouzhe/my_fuzz/pdf2json/src/pdf2json+0x41b198)

0x606000004580 is located 0 bytes inside of 64-byte region [0x606000004580,0x6060000045c0)
allocated by thread T0 here:
    #0 0x4df3c8 in __interceptor_malloc /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:88
    #1 0x8dcbc3 in grealloc /home/fouzhe/my_fuzz/pdf2json/goo/gmem.cc:143:9

SUMMARY: AddressSanitizer: alloc-dealloc-mismatch /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:149 in operator delete(void*)
==22708==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==22708==ABORTING

Alloc_dealloc_mismatch in function CSStyle

I use Clang 6.0 and AddressSanitizer to build pdf2json v0.69, this file can cause alloc-dealloc-mismatch with the following command:

./pdf2json alloc_dealloc_mismatch_CSStyle.pdf 1.json

This is the ASAN information:

=================================================================
==28963==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x603000017230
    #0 0x517bd0 in operator delete(void*) /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:149
    #1 0x537741 in XmlFontAccu::CSStyle(int, int) /home/fouzhe/my_fuzz/pdf2json/src/XmlFonts.cc:392:4
    #2 0x523af4 in HtmlPage::dumpAsXML(_IO_FILE*, int, int, int) /home/fouzhe/my_fuzz/pdf2json/src/ImgOutputDev.cc:618:35
    #3 0x52a724 in HtmlPage::dump(_IO_FILE*, int, int, int) /home/fouzhe/my_fuzz/pdf2json/src/ImgOutputDev.cc:712:14
    #4 0x52a724 in ImgOutputDev::endPage() /home/fouzhe/my_fuzz/pdf2json/src/ImgOutputDev.cc:1036
    #5 0x78c975 in Gfx::~Gfx() /home/fouzhe/my_fuzz/pdf2json/xpdf/Gfx.cc:530:10
    #6 0x60aa91 in Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/Page.cc:359:3
    #7 0x609810 in Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/Page.cc:265:3
    #8 0x60feb5 in PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/PDFDoc.cc:319:27
    #9 0x60feb5 in PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) /home/fouzhe/my_fuzz/pdf2json/xpdf/PDFDoc.cc:332
    #10 0x53c946 in main /home/fouzhe/my_fuzz/pdf2json/src/pdf2json.cc:275:10
    #11 0x7f619da1082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #12 0x41b198 in _start (/home/fouzhe/my_fuzz/pdf2json/src/pdf2json+0x41b198)

0x603000017230 is located 0 bytes inside of 20-byte region [0x603000017230,0x603000017244)
allocated by thread T0 here:
    #0 0x517008 in operator new[](unsigned long) /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:95
    #1 0x53749b in XmlFontAccu::CSStyle(int, int) /home/fouzhe/my_fuzz/pdf2json/src/XmlFonts.cc:363:19
    #2 0x523af4 in HtmlPage::dumpAsXML(_IO_FILE*, int, int, int) /home/fouzhe/my_fuzz/pdf2json/src/ImgOutputDev.cc:618:35

SUMMARY: AddressSanitizer: alloc-dealloc-mismatch /home/fouzhe/llvm/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:149 in operator delete(void*)
==28963==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==28963==ABORTING

Segmentation fault on ObjectStream::getObject

We’ve fuzzed pdf2json with AFL and found some crashes on ObjectStream::getObject.

gdb says :

Error (35014): Dictionary key must be a name object
Error (35021): Dictionary key must be a name object

Program received signal SIGSEGV, Segmentation fault.
0x0000555555665ccc in ObjectStream::getObject (obj=0x555555aacfe8, objNum=67,
    objIdx=432, this=0x555555ac9ee0) at XRef.cc:183
183	  if (objIdx < 0 || objIdx >= nObjects || objNum != objNums[objIdx]) {

gdb backtrace stack says :

(gdb) bt
#0  0x0000555555665ccc in ObjectStream::getObject (obj=0x555555aacfe8, objNum=67,
    objIdx=432, this=0x555555ac9ee0) at XRef.cc:183
#1  XRef::fetch (this=0x555555a9c500, num=67, gen=<optimized out>,
    obj=obj@entry=0x555555aacfe8) at XRef.cc:841
#2  0x00005555556092a5 in Object::fetch (this=<optimized out>, xref=<optimized out>,
    obj=obj@entry=0x555555aacfe8) at Object.cc:105
#3  0x000055555559831e in Dict::lookup (this=<optimized out>,
    key=key@entry=0x55555582a68f "StructTreeRoot", obj=obj@entry=0x555555aacfe8)
    at Dict.cc:76
#4  0x00005555555941f6 in Object::dictLookup (this=0x7fffffffe1e0, obj=0x555555aacfe8,
    key=0x55555582a68f "StructTreeRoot") at Object.h:253
#5  Catalog::Catalog (this=0x555555aacf90, xrefA=<optimized out>) at Catalog.cc:113
#6  0x0000555555614fb9 in PDFDoc::setup (userPassword=0x0, ownerPassword=<optimized out>,
    this=0x555555aa7ba0) at PDFDoc.cc:201
#7  PDFDoc::PDFDoc (this=0x555555aa7ba0, fileNameA=<optimized out>,
    ownerPassword=<optimized out>, userPassword=0x0, guiDataA=<optimized out>)
    at PDFDoc.cc:101
#8  0x000055555558bdba in main (argc=<optimized out>, argv=0x7fffffffe4b8)
    at pdf2json.cc:159

Tabs in text

Hello all,
I have found an odd scenario whereby tabs in the PDF text result in no output. For example:
This->is->separated->by->tabs
results in
Thisisseparatedbytabs

I am happy to look at the code if someone might be able to point me at where the text stream is handled.

Aborted on DCTStream::decodeImage

Hi,

Our fuzzer found a bug due to an invalid read on the function DCTStream::decodeImage (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_aborted_DCTStream::decodeImage

Valgrind says:

valgrind pdf2json $PoC /dev/null
==17382== Memcheck, a memory error detector
==17382== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==17382== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==17382== Command: ./pdf2json ./PoC_aborted_DCTStream::decodeImage /dev/null
==17382== 
Error: PDF file is damaged - attempting to reconstruct xref table...
Error (15396): Illegal character <5c> in hex string
Error (15407): Illegal character <78> in hex string
Error (154): Dictionary key must be a name object
Error (165): Dictionary key must be a name object
Error (528): Dictionary key must be a name object
Error (530): Dictionary key must be a name object
Error (532): Dictionary key must be a name object
Error (536): Dictionary key must be a name object
Error (539): Dictionary key must be a name object
Error (545): Dictionary key must be a name object
Error (8015): Command token too long
Error (8139): Missing 'endstream'
Error (1970): Unknown DCT marker <75>
==17382== Invalid read of size 4
==17382==    at 0x435431: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x5b5bf10 is 0 bytes after a block of size 100,352 alloc'd
==17382==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17382==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432BC5: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382== 
==17382== Invalid read of size 4
==17382==    at 0x435452: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x5b5bf14 is 4 bytes after a block of size 100,352 alloc'd
==17382==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17382==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432BC5: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382== 
==17382== Invalid read of size 4
==17382==    at 0x43546F: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x5b5bf18 is 8 bytes after a block of size 100,352 alloc'd
==17382==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17382==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432BC5: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382== 
==17382== Invalid read of size 4
==17382==    at 0x43548C: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x5b5bf1c is 12 bytes after a block of size 100,352 alloc'd
==17382==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17382==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432BC5: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382== 
==17382== Invalid read of size 4
==17382==    at 0x4354A9: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x5b5bf20 is 16 bytes after a block of size 100,352 alloc'd
==17382==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17382==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432BC5: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382== 
==17382== Invalid read of size 4
==17382==    at 0x4354C6: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x5b5bf24 is 20 bytes after a block of size 100,352 alloc'd
==17382==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17382==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432BC5: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382== 
==17382== Invalid read of size 4
==17382==    at 0x4354E3: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x5b5bf28 is 24 bytes after a block of size 100,352 in arena "client"
==17382== 
==17382== Invalid read of size 4
==17382==    at 0x435500: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x5b5bf2c is 28 bytes after a block of size 100,352 in arena "client"
==17382== 
==17382== Invalid read of size 1
==17382==    at 0x43698B: DCTStream::transformDataUnit(unsigned short*, int*, unsigned char*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x43555E: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  Address 0x6feabb is not stack'd, malloc'd or (recently) free'd
==17382== 
==17382== 
==17382== Process terminating with default action of signal 11 (SIGSEGV)
==17382==  Access not within mapped region at address 0x6FEABB
==17382==    at 0x43698B: DCTStream::transformDataUnit(unsigned short*, int*, unsigned char*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x43555E: DCTStream::decodeImage() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x432C6C: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17382==    by 0x40269A: main (pdf2json.cc:275)
==17382==  If you believe this happened as a result of a stack
==17382==  overflow in your program's main thread (unlikely but
==17382==  possible), you can try to increase the size of the
==17382==  main thread stack using the --main-stacksize= flag.
==17382==  The main thread stack size used in this run was 8388608.
==17382== 
==17382== HEAP SUMMARY:
==17382==     in use at exit: 518,164 bytes in 1,769 blocks
==17382==   total heap usage: 1,978 allocs, 209 frees, 609,684 bytes allocated
==17382== 
==17382== LEAK SUMMARY:
==17382==    definitely lost: 16 bytes in 1 blocks
==17382==    indirectly lost: 8 bytes in 1 blocks
==17382==      possibly lost: 0 bytes in 0 blocks
==17382==    still reachable: 518,140 bytes in 1,767 blocks
==17382==         suppressed: 0 bytes in 0 blocks
==17382== Rerun with --leak-check=full to see details of leaked memory
==17382== 
==17382== For counts of detected and suppressed errors, rerun with: -v
==17382== ERROR SUMMARY: 57 errors from 9 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

HEAP OVERFLOW VULNERABILITY

In CharCodeToUnicode.cc::264
!pst->getToken(tok3, sizeof(tok3), &n3) || //sizeof(tok3) == 256
here n3 can be a value from 0 to 256 - 2

In CharCodeToUnicode.cc::298
addMapping(code1, tok3 + 1, n3 - 2, i);

In CharCodeToUnicode.cc::313
if (n <= 4) {
if (sscanf(uStr, "%x", &u) != 1) {
error(-1, "Illegal entry in ToUnicode CMap");
return;
}
map[code] = u + offset;
} else {
if (sMapLen >= sMapSize) {
sMapSize = sMapSize + 16;
sMap = (CharCodeToUnicodeString *)
greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString));
}
map[code] = 0;
sMap[sMapLen].c = code;
sMap[sMapLen].len = n / 4;

The parameter n of void CharCodeToUnicode::addMapping(CharCode code, char *uStr, int n, int offset) can be a bigger value than the the limited value maxUnicodeString
In CharCodeToUnicode.cc::350
sMap[sMapLen].u[sMap[sMapLen].len - 1] += offset;

Using the sample pdf file , we can find the VUL clearly.
sMapLen = 0xf
sMap = 0x6f56f0
pwndbg> p sMap[0xf]
$8 = {
c = 51,
u = {0, 17039378, 4784134, 7208965, 2686984, 14, 542, 185},
len = 12
}

pwndbg> p sMap[sMapLen].len
$9 = 12

so sMap[sMapLen].len - 1 = 13, which makes the array Unicode u[maxUnicodeString]; as follows oob write.
#define maxUnicodeString 8

struct CharCodeToUnicodeString {
CharCode c;
Unicode u[maxUnicodeString];
int len;
};

So, we can modify memory from offset 0 to 63 * 4 with type unsigned int by adding the original value with offset, which can still be controlled. Local command execution is possible using heap fengshui, especially in the linux machine using glibc version > 2.6. Free a chunk using the bigger fake size can lead to continuously heap buf overflow, which can make the hacker get a memory containing the function pointer and then achieve the purpose of command execution.

SEGV (NULL pointer dereference) on DCTStream::getChar

Hi,

Our fuzzer found a crash due to a NULL pointer dereference bug on the function DCTStream::getChar (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_npd_DCTStream::getChar

valgrind pdf2json $PoC /dev/null
==20313== Memcheck, a memory error detector
==20313== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==20313== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==20313== Command: ./pdf2json PoC_npd_DCTStream::getChar /dev/null
==20313== 
Error (13143): Badly formatted number
Error: PDF file is damaged - attempting to reconstruct xref table...
Error (13759): Illegal character '>'
Error (7369): Dictionary key must be a name object
Error (7379): Dictionary key must be a name object
Error (7380): Illegal character '>'
Error (7380): Dictionary key must be a name object
Error (7388): Dictionary key must be a name object
Error (7394): Dictionary key must be a name object
Error (7853): Dictionary key must be a name object
Error (7903): Dictionary key must be a name object
Error (7913): Dictionary key must be a name object
Error (7920): Dictionary key must be a name object
Error (7922): Dictionary key must be a name object
Error (7924): Dictionary key must be a name object
Error (7928): Dictionary key must be a name object
Error (7933): Dictionary key must be a name object
Error (7940): Dictionary key must be a name object
Error (7943): Dictionary key must be a name object
Error (7945): Dictionary key must be a name object
Error (7949): Dictionary key must be a name object
Error (7960): Dictionary key must be a name object
Error (7972): Dictionary key must be a name object
Error (7976): Dictionary key must be a name object
Error (7979): Dictionary key must be a name object
Error (7987): Dictionary key must be a name object
==20313== Invalid read of size 1
==20313==    at 0x433044: DCTStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x487A83: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x4890DF: Parser::Parser(XRef*, Lexer*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x4542F8: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x40269A: main (pdf2json.cc:275)
==20313==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==20313== 
==20313== 
==20313== Process terminating with default action of signal 11 (SIGSEGV)
==20313==  Access not within mapped region at address 0x0
==20313==    at 0x433044: DCTStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x487A83: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x4890DF: Parser::Parser(XRef*, Lexer*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x4542F8: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==20313==    by 0x40269A: main (pdf2json.cc:275)
==20313==  If you believe this happened as a result of a stack
==20313==  overflow in your program's main thread (unlikely but
==20313==  possible), you can try to increase the size of the
==20313==  main thread stack using the --main-stacksize= flag.
==20313==  The main thread stack size used in this run was 8388608.
==20313== 
==20313== HEAP SUMMARY:
==20313==     in use at exit: 225,178 bytes in 1,772 blocks
==20313==   total heap usage: 2,047 allocs, 275 frees, 341,335 bytes allocated
==20313== 
==20313== LEAK SUMMARY:
==20313==    definitely lost: 16 bytes in 1 blocks
==20313==    indirectly lost: 8 bytes in 1 blocks
==20313==      possibly lost: 0 bytes in 0 blocks
==20313==    still reachable: 225,154 bytes in 1,770 blocks
==20313==         suppressed: 0 bytes in 0 blocks
==20313== Rerun with --leak-check=full to see details of leaked memory
==20313== 
==20313== For counts of detected and suppressed errors, rerun with: -v
==20313== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

Possible to stream input PDF from stdin instead of providing a path?

I would like to use this library in some python code using the python subprocess library like so:

p = subprocess.Popen(['pdf2json'], stdin=pythonfile, stdout=subprocess.PIPE)

The reason I want to do this is so I don't have to save the file to disk and can do everything in memory.

Is this possible right now, or any suggestions on how to accomplish this?

php exec pdfjson comand (CentOS)

hello how to run command by php?
try run <?php exec ('/usr/local/bin/pdf2json /path/Page.pdf -enc UTF-8 -compress -split 10 /path/Paper.pdf_%.js ')
not effect

co-ordinates eem to have no relation to co-ordinates for object

I have been trying to work out where objects are on the page and your Height and Width for the page makes no sense at all. for example I just had a look and m PDF is: H 842 x w 959 but your software is reporting it at H: 1262 x W: 892

The same goes for elements, I cannot work any of this out.

Top in the PDF says: 204, but the export form your software says: 963
L in acrobat says 219, yours says: 332 I cannot see any relationship at all between any of it. Please help!

I don't know C++ so I am unable to understand exactly what this is doing and how it is calculating things.

Paul

SEGV (use after free) on DCTStream::transformDataUnit

Hi,

Our fuzzer found a crash due to an Use After Free bug on the function DCTStream::transformDataUnit (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_uaf_DCTStream::transformDataUnit

Valgrind says:

pdf2json $PoC /dev/null
...
==12935== Invalid read of size 2
==12935==    at 0x436149: DCTStream::transformDataUnit(unsigned short*, int*, unsigned char*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x43363B: DCTStream::readMCURow() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4331D7: DCTStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4887E8: Object::streamLookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x487A5B: Lexer::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4884C8: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==  Address 0x5b21c10 is 16 bytes inside a block of size 32 free'd
==12935==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12935==    by 0x428565: Object::free() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x446431: Array::~Array() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42855D: Object::free() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x446431: Array::~Array() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42855D: Object::free() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x446431: Array::~Array() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42855D: Object::free() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x446431: Array::~Array() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42855D: Object::free() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x446431: Array::~Array() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42855D: Object::free() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==  Block was alloc'd at
==12935==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12935==    by 0x428284: Object::initArray(XRef*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x48924E: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935== 
==12935== Invalid read of size 1
==12935==    at 0x43698B: DCTStream::transformDataUnit(unsigned short*, int*, unsigned char*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x43363B: DCTStream::readMCURow() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4331D7: DCTStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4887E8: Object::streamLookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x487A5B: Lexer::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4884C8: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==  Address 0x6ff09c is not stack'd, malloc'd or (recently) free'd
==12935== 
==12935== 
==12935== Process terminating with default action of signal 11 (SIGSEGV)
==12935==  Access not within mapped region at address 0x6FF09C
==12935==    at 0x43698B: DCTStream::transformDataUnit(unsigned short*, int*, unsigned char*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x43363B: DCTStream::readMCURow() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4331D7: DCTStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4887E8: Object::streamLookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x487A5B: Lexer::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4884C8: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x4892BE: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==12935==  If you believe this happened as a result of a stack
==12935==  overflow in your program's main thread (unlikely but
==12935==  possible), you can try to increase the size of the
==12935==  main thread stack using the --main-stacksize= flag.
==12935==  The main thread stack size used in this run was 8388608.
==12935== 
==12935== HEAP SUMMARY:
==12935==     in use at exit: 227,902 bytes in 1,796 blocks
==12935==   total heap usage: 2,505 allocs, 709 frees, 362,560 bytes allocated
==12935== 
==12935== LEAK SUMMARY:
==12935==    definitely lost: 16 bytes in 1 blocks
==12935==    indirectly lost: 8 bytes in 1 blocks
==12935==      possibly lost: 0 bytes in 0 blocks
==12935==    still reachable: 227,878 bytes in 1,794 blocks
==12935==         suppressed: 0 bytes in 0 blocks
==12935== Rerun with --leak-check=full to see details of leaked memory
==12935== 
==12935== For counts of detected and suppressed errors, rerun with: -v
==12935== ERROR SUMMARY: 1921 errors from 3 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

Empty files

pdf2json has been working for me with most PDFs however I recently came across a book where the JSON files are empty of any content. Wondering if you have any idea what might cause a file to come up empty like this?

For example:

[{"number":50,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]},{"number":51,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]},{"number":52,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]},{"number":53,"pages":90,"height":1188,"width":918,"fonts":[{"fontspec":"33","size":"24","family":"Times","color":"#000000"}],"text":[]},{"number":54,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]},{"number":55,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]},{"number":56,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]},{"number":57,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]},{"number":58,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]},{"number":59,"pages":90,"height":1188,"width":918,"fonts":[],"text":[]}]

SEGV (stack overflow) on XRef::fetch

Hi,

Our fuzzer found a crash due to a stack overflow bug on the function XRef::fetch (the latest commit b671b64 on master - version 0.70).

PoC_so_XRef::fetch: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_so_XRef::fetch

Valgrind says:

valgrind pdf2json PoC_so_XRef\:\:fetch /dev/null
==17786== Memcheck, a memory error detector
==17786== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==17786== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==17786== Command: ./pdf2json PoC_so_XRef::fetch /dev/null
==17786== 
==17786== Stack overflow in thread #1: can't grow stack to 0xffe801000
==17786== 
==17786== Process terminating with default action of signal 11 (SIGSEGV)
==17786==  Access not within mapped region at address 0xFFE801FF8
==17786== Stack overflow in thread #1: can't grow stack to 0xffe801000
==17786==    at 0x4090A2: Object::Object() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43F7AB: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43CE5B: ObjectStream::ObjectStream(XRef*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43FB1F: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43CE5B: ObjectStream::ObjectStream(XRef*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43FB1F: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43CE5B: ObjectStream::ObjectStream(XRef*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43FB1F: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43CE5B: ObjectStream::ObjectStream(XRef*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43FB1F: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43CE5B: ObjectStream::ObjectStream(XRef*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==    by 0x43FB1F: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==17786==  If you believe this happened as a result of a stack
==17786==  overflow in your program's main thread (unlikely but
==17786==  possible), you can try to increase the size of the
==17786==  main thread stack using the --main-stacksize= flag.
==17786==  The main thread stack size used in this run was 8388608.
==17786== Stack overflow in thread #1: can't grow stack to 0xffe801000
==17786== 
==17786== Process terminating with default action of signal 11 (SIGSEGV)
==17786==  Access not within mapped region at address 0xFFE801FF8
==17786== Stack overflow in thread #1: can't grow stack to 0xffe801000
==17786==    at 0x4A28680: _vgnU_freeres (in /usr/lib/valgrind/vgpreload_core-amd64-linux.so)
==17786==  If you believe this happened as a result of a stack
==17786==  overflow in your program's main thread (unlikely but
==17786==  possible), you can try to increase the size of the
==17786==  main thread stack using the --main-stacksize= flag.
==17786==  The main thread stack size used in this run was 8388608.
==17786== 
==17786== HEAP SUMMARY:
==17786==     in use at exit: 836,551 bytes in 27,879 blocks
==17786==   total heap usage: 27,938 allocs, 59 frees, 946,615 bytes allocated
==17786== 
==17786== LEAK SUMMARY:
==17786==    definitely lost: 0 bytes in 0 blocks
==17786==    indirectly lost: 0 bytes in 0 blocks
==17786==      possibly lost: 0 bytes in 0 blocks
==17786==    still reachable: 836,551 bytes in 27,879 blocks
==17786==         suppressed: 0 bytes in 0 blocks
==17786== Rerun with --leak-check=full to see details of leaked memory
==17786== 
==17786== For counts of detected and suppressed errors, rerun with: -v
==17786== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

Compilation throws "forbidden conversion" warnings

g++ version: g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
pdf2json version: 0.70
chunck of the trace:

ImgOutputDev.cc:833:66: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   glMetaVars->append(new HtmlMetaVar("generator", "pdf2json 0.70"));
                                                                  ^
ImgOutputDev.cc:833:66: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
ImgOutputDev.cc:834:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   if( author ) glMetaVars->append(new HtmlMetaVar("author", author));
                                                                   ^

SEGV on CCITTFaxStream::lookChar

Hi,

Our fuzzer found a crash due to an invalid write on the function CCITTFaxStream::lookChar (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_seg_CCITTFaxStream::lookChar

Valgrind says:

valgrind pdf2json $PoC /dev/null
==15436== Memcheck, a memory error detector
==15436== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==15436== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==15436== Command: ./pdf2json ./PoC_segv_CCITTFaxStream::lookChar /dev/null
==15436== 
...
==15436== Invalid write of size 2
==15436==    at 0x431600: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100bc is 0 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x43162B: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100bc is 0 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x43154B: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100bc is 0 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
==15436== Invalid write of size 2
==15436==    at 0x431556: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100be is 2 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x431581: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100be is 2 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x4315F5: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100be is 2 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
Error (5428): Bad white code (000b) in CCITTFax stream
==15436== Invalid read of size 2
==15436==    at 0x43165C: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b1040a is 22 bytes before a block of size 8 alloc'd
==15436==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x40A204: GfxDeviceGrayColorSpace::copy() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41AF23: GfxState::GfxState(GfxState*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41CDB8: GfxState::copy() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41C749: GfxState::save() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x467BC1: Gfx::saveState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A586: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40269A: main (pdf2json.cc:275)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x431688: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b1040a is 22 bytes before a block of size 8 alloc'd
==15436==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x40A204: GfxDeviceGrayColorSpace::copy() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41AF23: GfxState::GfxState(GfxState*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41CDB8: GfxState::copy() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41C749: GfxState::save() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x467BC1: Gfx::saveState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A586: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40269A: main (pdf2json.cc:275)
==15436== 
Error (5585): CCITTFax row is wrong length (101)
==15436== Invalid read of size 2
==15436==    at 0x4316CF: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b1040a is 22 bytes before a block of size 8 alloc'd
==15436==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x40A204: GfxDeviceGrayColorSpace::copy() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41AF23: GfxState::GfxState(GfxState*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41CDB8: GfxState::copy() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41C749: GfxState::save() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x467BC1: Gfx::saveState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A586: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40269A: main (pdf2json.cc:275)
==15436== 
==15436== Invalid write of size 2
==15436==    at 0x431722: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b1040a is 22 bytes before a block of size 8 alloc'd
==15436==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x40A204: GfxDeviceGrayColorSpace::copy() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41AF23: GfxState::GfxState(GfxState*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41CDB8: GfxState::copy() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x41C749: GfxState::save() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x467BC1: Gfx::saveState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A586: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40269A: main (pdf2json.cc:275)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x431C78: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100bc is 0 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x431C4C: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100bc is 0 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x431C95: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100bc is 0 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
==15436== Invalid read of size 2
==15436==    at 0x431CBF: CCITTFaxStream::lookChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43ADDC: CCITTFaxStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4884FD: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==  Address 0x5b100bc is 0 bytes after a block of size 108 alloc'd
==15436==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15436==    by 0x48E521: gmalloc (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x48E667: gmallocn (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43051F: CCITTFaxStream::CCITTFaxStream(Stream*, int, int, int, int, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42CE76: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42C6AF: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436== 
Error: Unknown operator '��������������������������������������'
Error: Unknown operator '?������?�������?�����������0'
Error: Unknown operator '�������������������?����?�'
==15436== Invalid write of size 8
==15436==    at 0x41C7A2: GfxState::restore() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x467BEB: Gfx::restoreState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A5AA: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40269A: main (pdf2json.cc:275)
==15436==  Address 0xfdccfdb8fdb30035 is not stack'd, malloc'd or (recently) free'd
==15436== 
==15436== 
==15436== Process terminating with default action of signal 11 (SIGSEGV)
==15436==  General Protection Fault
==15436==    at 0x41C7A2: GfxState::restore() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x467BEB: Gfx::restoreState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A5AA: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==15436==    by 0x40269A: main (pdf2json.cc:275)
==15436== 
==15436== HEAP SUMMARY:
==15436==     in use at exit: 211,954 bytes in 1,760 blocks
==15436==   total heap usage: 2,027 allocs, 267 frees, 304,086 bytes allocated
==15436== 
==15436== LEAK SUMMARY:
==15436==    definitely lost: 760 bytes in 4 blocks
==15436==    indirectly lost: 192 bytes in 5 blocks
==15436==      possibly lost: 0 bytes in 0 blocks
==15436==    still reachable: 211,002 bytes in 1,751 blocks
==15436==         suppressed: 0 bytes in 0 blocks
==15436== Rerun with --leak-check=full to see details of leaked memory
==15436== 
==15436== For counts of detected and suppressed errors, rerun with: -v
==15436== ERROR SUMMARY: 483 errors from 15 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

memory leaks in GString::copy()/Page::getLinks/GString::resize

project

https://github.com/flexpaper/pdf2json
version: 0.70

os info

Ubuntu20.04 TLS

poc

poc.zip

build

git https://github.com/flexpaper/pdf2json.git
cd pdf2json
./configure

edit pdf2json/src/Makefile as follows

SHELL = /bin/sh

SRCDIR = .
XPDFSRCDIR = ../xpdf
XPDFLIBDIR = ../xpdf
GOOSRCDIR = ../goo
GOOLIBDIR = ../goo
FOFISRCDIR = ../fofi
FOFILIBDIR = ../fofi
SPLASHSRCDIR = ../splash
SPLASHLIBDIR = ../splash

CXXFLAGS = -I/usr/local/include -g -O2 -fsanitize=address -fno-omit-frame-pointer -DHAVE_CONFIG_H -DHAVE_DIRENT_H=1  -I.. -DHAVE_REWINDDIR=1 -DHAVE_POPEN=1 -I.. -I$(GOOSRCDIR) -I$(XPDFSRCDIR) -I$(FOFISRCDIR) -I$(SPLASHSRCDIR) -I$(srcdir)           -I/usr/X11R6/include

LDFLAGS =
FTLIBS =

OTHERLIBS =

CXX ?= c++

LIBPREFIX = lib
EXE =

#------------------------------------------------------------------------

.SUFFIXES: .cc

.cc.o:
	$(CXX) $(CXXFLAGS) -c $<

#------------------------------------------------------------------------

CXX_SRC = \
	$(SRCDIR)/pdf2json.cc \
	$(SRCDIR)/ImgOutputDev.cc \
	$(SRCDIR)/XmlFonts.cc \
	$(SRCDIR)/XmlLinks.cc

#------------------------------------------------------------------------

all: pdf2json$(EXE)

#-------------------------------------------------------------------------

PDF2JSON_OBJS = ImgOutputDev.o XmlFonts.o XmlLinks.o \
    pdf2json.o
PDF2JSON_LIBS = -L$(GOOLIBDIR) -L$(FOFILIBDIR) -L$(SPLASHLIBDIR) $(FTLIBS) -L$(XPDFLIBDIR) $(OTHERLIBS) -lXpdf -lGoo -lfofi -lsplash -lm

pdf2json$(EXE): $(PDF2JSON_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdf2json$(EXE) $(PDF2JSON_OBJS) \
		$(PDF2JSON_LIBS)

#-------------------------------------------------------------------------
PDF2JSON_WINOBJS = pdf2json.exe ImgOutPutDev.obj  pdf2json.obj  XmlFonts.obj  XmlLinks.obj

clean:
	rm -f $(PDF2JSON_OBJS) pdf2json$(EXE)
	rm -f $(PDF2JSON_WINOBJS)

#------------------------------------------------------------------------

distdepend:
	cp Makefile.in Makefile.in.bak
	sed '/^#----- dependences -----/q' Makefile.in.bak >Makefile.in
	$(CXX) $(CXXFLAGS) -MM $(CXX_SRC) >>Makefile.in

to pdf2json dir, make!

make

Info

Error: PDF file is damaged - attempting to reconstruct xref table...
Error (5457): Dictionary key must be a name object
Error (5459): Dictionary key must be a name object
Error (5463): Dictionary key must be a name object
Error (5466): Dictionary key must be a name object
Error (5472): Dictionary key must be a name object
Error (4932): Dictionary key must be a name object
Error (4934): Dictionary key must be a name object
Error (4938): Dictionary key must be a name object
Error (4942): Dictionary key must be a name object
Error (4943): Dictionary key must be a name object
Error (4950): Dictionary key must be a name object
Page-1

=================================================================
==2270915==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x4c736d in operator new(unsigned long) (/home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/src/pdf2json+0x4c736d)
    #1 0x53b9b4 in GString::copy() /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/xpdf/./../goo/GString.h:41:28
    #2 0x53b9b4 in GlobalParams::getTextEncodingName() /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/xpdf/GlobalParams.cc:2256:21
    #3 0x4d0b77 in ImgOutputDev::ImgOutputDev(char*, char*, char*, char*, char*, char*, char*, int, int, int, int, int, int, int) /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/src/ImgOutputDev.cc:864:52
    #4 0x4dd020 in main /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/src/pdf2json.cc:241:17
    #5 0x7f63af21d082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x4c736d in operator new(unsigned long) (/home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/src/pdf2json+0x4c736d)
    #1 0x54c541 in Page::getLinks(Catalog*) /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/xpdf/Page.cc:254:11
    #2 0x550190 in PDFDoc::getLinks(int) /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/xpdf/PDFDoc.cc:351:34
    #3 0x550190 in PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/xpdf/PDFDoc.cc:320:34
    #4 0x550190 in PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/xpdf/PDFDoc.cc:332:5
    #5 0x4dd214 in main /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/src/pdf2json.cc:275:10
    #6 0x7f63af21d082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

Indirect leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x4c747d in operator new[](unsigned long) (/home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/src/pdf2json+0x4c747d)
    #1 0x69f3f2 in GString::resize(int) /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/goo/GString.cc:87:9
    #2 0x69f3f2 in GString::GString(GString*) /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/goo/GString.cc:131:3
    #3 0x4d0b77 in ImgOutputDev::ImgOutputDev(char*, char*, char*, char*, char*, char*, char*, int, int, int, int, int, int, int) /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/src/ImgOutputDev.cc:864:52
    #4 0x4dd020 in main /home/ubuntu/fuzz/pdf2json_fuzz/pdf2json/src/pdf2json.cc:241:17
    #5 0x7f63af21d082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

Split option names files incorrectly

If I use the -split option with 10 files are named - Paper.pdf_10.js, _20.js, _30.js...

However if i split with 1 or 5 (the two i tried) the count begins at 2 or 10 on the 2nd nth factor.

I am using windows 8 64bit

SEGV on DCTStream::reset

Hi,

Our fuzzer found a crash due to an invalid write on the function DCTStream::reset (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_segv_DCTStream::reset

Valgrind says:

valgrind pdf2json $PoC /dev/null
==5144== Memcheck, a memory error detector
==5144== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==5144== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==5144== Command: ./pdf2json ./PoC_segv_DCTStream::reset /dev/null
==5144== 
Error (13145): Illegal character ')'
Error: PDF file is damaged - attempting to reconstruct xref table...
Error (7397): Dictionary key must be a name object
Error (7407): Dictionary key must be a name object
Error (7408): Illegal character '>'
Error (7408): Dictionary key must be a name object
Error (7416): Dictionary key must be a name object
Error (7422): Dictionary key must be a name object
Error (7905): Dictionary key must be a name object
Error (7955): Dictionary key must be a name object
Error (7965): Dictionary key must be a name object
Error (7972): Dictionary key must be a name object
Error (7974): Dictionary key must be a name object
Error (7976): Dictionary key must be a name object
Error (7980): Dictionary key must be a name object
Error (7985): Dictionary key must be a name object
Error (7992): Dictionary key must be a name object
Error (7995): Dictionary key must be a name object
Error (7997): Dictionary key must be a name object
Error (8001): Dictionary key must be a name object
Error (8012): Dictionary key must be a name object
Error (8024): Dictionary key must be a name object
Error (8028): Dictionary key must be a name object
Error (8031): Dictionary key must be a name object
Error (8039): Dictionary key must be a name object
==5144== Invalid write of size 8
==5144==    at 0x432D2D: DCTStream::reset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x40941E: Object::streamReset() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x48788A: Lexer::Lexer(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x4542CE: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x40269A: main (pdf2json.cc:275)
==5144==  Address 0x5b1b218 is 0 bytes after a block of size 4,584 alloc'd
==5144==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5144==    by 0x42CF21: Stream::makeFilter(char*, Stream*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42C777: Stream::addFilters(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x489AFF: Parser::makeStream(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x489549: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x43FA44: XRef::fetch(int, int, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x4284A9: Object::fetch(XRef*, Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A565: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x40269A: main (pdf2json.cc:275)
==5144== 
==5144== Conditional jump or move depends on uninitialised value(s)
==5144==    at 0x436A29: DCTStream::readHuffSym(DCTHuffTable*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x434B49: DCTStream::readDataUnit(DCTHuffTable*, DCTHuffTable*, int*, int*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x4335CF: DCTStream::readMCURow() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x432FB6: DCTStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x487A83: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x4890DF: Parser::Parser(XRef*, Lexer*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x4542F8: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144== 
Error (8504): Bad Huffman code in DCT stream
==5144== Use of uninitialised value of size 8
==5144==    at 0x41ACFE: GfxState::~GfxState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x41C839: GfxState::restore() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x467BEB: Gfx::restoreState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A5AA: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x40269A: main (pdf2json.cc:275)
==5144== 
==5144== Invalid read of size 8
==5144==    at 0x41ACFE: GfxState::~GfxState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x41C839: GfxState::restore() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x467BEB: Gfx::restoreState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A5AA: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x40269A: main (pdf2json.cc:275)
==5144==  Address 0x8 is not stack'd, malloc'd or (recently) free'd
==5144== 
==5144== 
==5144== Process terminating with default action of signal 11 (SIGSEGV)
==5144==  Access not within mapped region at address 0x8
==5144==    at 0x41ACFE: GfxState::~GfxState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x41C839: GfxState::restore() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x467BEB: Gfx::restoreState() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A5AA: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BCBD: PDFDoc::displayPage(OutputDev*, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x42BD48: PDFDoc::displayPages(OutputDev*, int, int, double, double, int, int, int, int, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==5144==    by 0x40269A: main (pdf2json.cc:275)
==5144==  If you believe this happened as a result of a stack
==5144==  overflow in your program's main thread (unlikely but
==5144==  possible), you can try to increase the size of the
==5144==  main thread stack using the --main-stacksize= flag.
==5144==  The main thread stack size used in this run was 8388608.
==5144== 
==5144== HEAP SUMMARY:
==5144==     in use at exit: 246,401 bytes in 1,945 blocks
==5144==   total heap usage: 2,354 allocs, 409 frees, 378,948 bytes allocated
==5144== 
==5144== LEAK SUMMARY:
==5144==    definitely lost: 18,992 bytes in 161 blocks
==5144==    indirectly lost: 8 bytes in 1 blocks
==5144==      possibly lost: 0 bytes in 0 blocks
==5144==    still reachable: 227,401 bytes in 1,783 blocks
==5144==         suppressed: 0 bytes in 0 blocks
==5144== Rerun with --leak-check=full to see details of leaked memory
==5144== 
==5144== For counts of detected and suppressed errors, rerun with: -v
==5144== Use --track-origins=yes to see where uninitialised values come from
==5144== ERROR SUMMARY: 27 errors from 4 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

Incompatible while installing on Ubuntu 14.04 x64

Hi,

I'm trying to install pdf2json on an Ubuntu 14.04 x64 hosted on digital ocean but I get an incompatibility error '/usr/local/bin/pdf2json: cannot execute binary file: Exec format error' when running pdf2json.
Is this package x64 compatible?

Thanks
Geo

Segmentation fault from Object.h

Hi, I found that pdf2json (commit b671b64) crashes with the attached file (pdf2json_crash.pdf) which has syntax errors. The crash was observed on Ubuntu 18.04.3 with kernel 4.15.0-72-generic and x86_64. The crash can be reproduced by the following command:

$ pdf2json pdf2json_crash.pdf

Here’s the the crash stack trace taken with GDB:

#0  0x00007ffff6e6930e in _int_malloc (av=av@entry=0x7ffff71c0c40 <main_arena>, bytes=bytes@entry=4) at malloc.c:3557
#1  0x00007ffff6e6c0fc in __GI___libc_malloc (bytes=4) at malloc.c:3057
#2  0x0000555555849e67 in gmalloc (size=4) at gmem.cc:97
#3  0x000055555584b009 in copyString (s=0x555556d6e0d4 "obj") at gmem.cc:261
#4  0x000055555582751d in Lexer::getObj (this=0x555556d6e0b0, obj=0x555556d6e088) at ./Object.h:103
#5  0x000055555582d8f7 in Parser::shift (this=0x555556d6e060) at Parser.cc:226
#6  0x000055555582bfa2 in Parser::getObj (this=0x555556d6e060, obj=0x7fffff7ff2a8, fileKey=0x0, encAlgorithm=cryptRC4, keyLength=0,
    objNum=0, objGen=0) at Parser.cc:108
#7  0x00005555556b6a99 in XRef::fetch (this=<optimized out>, num=5, gen=0, obj=0x7fffff7ff400) at XRef.cc:811
#8  0x0000555555653927 in Object::fetch (this=<optimized out>, xref=0x555555c708f0, obj=0x7fffff7ff400) at Object.cc:106
#9  0x00005555555c7eaa in Dict::lookup (this=0x555556d6dee0, key=0x5555558f21c1 "Length", obj=0x7fffff7ff400) at Dict.cc:76
#10 0x000055555582db60 in Object::dictLookup (this=<optimized out>, key=0x4 <error: Cannot access memory at address 0x4>,
    obj=0x55550000000d) at ./Object.h:253

This crash was found with Angora fuzzer, and pdf2json_crash is originated from sample pdf file dummy.pdf which is also attached.

Hope this help.

pdf2json_crash.pdf
dummy.pdf

SEGV on DCTStream::transformDataUnit

Hi,

Our fuzzer found a crash due to an invalid read on the function DCTStream::transformDataUnit (the latest commit b671b64 on master - version 0.70).

PoC: https://github.com/strongcourage/PoCs/blob/master/pdf2json_b671b64/PoC_segv_DCTStream::transformDataUnit

Valgrind says:

valgrind pdf2json $PoC /dev/null
...
==23848== Invalid read of size 1
==23848==    at 0x43698B: DCTStream::transformDataUnit(unsigned short*, int*, unsigned char*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x43363B: DCTStream::readMCURow() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x432FB6: DCTStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x487A83: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==  Address 0x6fd636 is not stack'd, malloc'd or (recently) free'd
==23848== 
==23848== 
==23848== Process terminating with default action of signal 11 (SIGSEGV)
==23848==  Access not within mapped region at address 0x6FD636
==23848==    at 0x43698B: DCTStream::transformDataUnit(unsigned short*, int*, unsigned char*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x43363B: DCTStream::readMCURow() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x432FB6: DCTStream::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x40947A: Object::streamGetChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x48796F: Lexer::getChar() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x487A83: Lexer::getObj(Object*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x489C19: Parser::shift() (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x489825: Parser::getObj(Object*, unsigned char*, CryptAlgorithm, int, int, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x454759: Gfx::go(int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x454311: Gfx::display(Object*, int) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x42A59E: Page::displaySlice(OutputDev*, double, double, int, int, int, int, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==    by 0x42A14A: Page::display(OutputDev*, double, double, int, int, int, Links*, int, Catalog*, int (*)(void*), void*) (in /home/dungnguyen/PoCs/pdf2json_b671b64/pdf2json)
==23848==  If you believe this happened as a result of a stack
==23848==  overflow in your program's main thread (unlikely but
==23848==  possible), you can try to increase the size of the
==23848==  main thread stack using the --main-stacksize= flag.
==23848==  The main thread stack size used in this run was 8388608.
==23848== 
==23848== HEAP SUMMARY:
==23848==     in use at exit: 230,627 bytes in 1,819 blocks
==23848==   total heap usage: 2,242 allocs, 423 frees, 357,101 bytes allocated
==23848== 
==23848== LEAK SUMMARY:
==23848==    definitely lost: 16 bytes in 1 blocks
==23848==    indirectly lost: 8 bytes in 1 blocks
==23848==      possibly lost: 0 bytes in 0 blocks
==23848==    still reachable: 230,603 bytes in 1,817 blocks
==23848==         suppressed: 0 bytes in 0 blocks
==23848== Rerun with --leak-check=full to see details of leaked memory
==23848== 
==23848== For counts of detected and suppressed errors, rerun with: -v
==23848== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault

Thanks,
Manh Dung

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.