diff options
author | Albert Astals Cid <aacid@kde.org> | 2019-11-26 11:45:26 +0100 |
---|---|---|
committer | Albert Astals Cid <tsdgeos@yahoo.es> | 2019-11-30 21:35:17 +0000 |
commit | 5be0c5cca3770b7096cfa7800fa8c419ced7e7e9 (patch) | |
tree | 6e55e6c6ef626deb56181984c5f0296abf770c6c | |
parent | 8d46550c4ff3d4a1923cfc4c42e3fd4d154a7624 (diff) |
Rework Hints::readTables a bit
fail and return immediately if the length is 0
also set ok to false in a few other "failed to read table" cases
-rw-r--r-- | poppler/Hints.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/poppler/Hints.cc b/poppler/Hints.cc index b9cc61fa..03e0f7e0 100644 --- a/poppler/Hints.cc +++ b/poppler/Hints.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2010, 2012 Hib Eris <hib@hiberis.nl> -// Copyright 2010, 2011, 2013, 2014, 2016-2018 Albert Astals Cid <aacid@kde.org> +// Copyright 2010, 2011, 2013, 2014, 2016-2019 Albert Astals Cid <aacid@kde.org> // Copyright 2010, 2013 Pino Toscano <pino@kde.org> // Copyright 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright 2014 Fabio D'Urso <fabiodurso@hotmail.it> @@ -184,20 +184,25 @@ void Hints::readTables(BaseStream *str, Linearization *linearization, XRef *xref hintsOffset2 = linearization->getHintsOffset2(); hintsLength2 = linearization->getHintsLength2(); - Parser *parser; + const unsigned int bufLength = hintsLength + hintsLength2; - int bufLength = hintsLength + hintsLength2; + if (bufLength == 0) { + ok = false; + return; + } std::vector<char> buf(bufLength); char *p = &buf[0]; - Stream *s = str->makeSubStream(hintsOffset, false, hintsLength, Object(objNull)); - s->reset(); - for (unsigned int i=0; i < hintsLength; i++) { *p++ = s->getChar(); } - delete s; + if (hintsOffset && hintsLength) { + Stream *s = str->makeSubStream(hintsOffset, false, hintsLength, Object(objNull)); + s->reset(); + for (unsigned int i=0; i < hintsLength; i++) { *p++ = s->getChar(); } + delete s; + } if (hintsOffset2 && hintsLength2) { - s = str->makeSubStream(hintsOffset2, false, hintsLength2, Object(objNull)); + Stream *s = str->makeSubStream(hintsOffset2, false, hintsLength2, Object(objNull)); s->reset(); for (unsigned int i=0; i < hintsLength2; i++) { *p++ = s->getChar(); } delete s; @@ -205,7 +210,7 @@ void Hints::readTables(BaseStream *str, Linearization *linearization, XRef *xref MemStream *memStream = new MemStream (&buf[0], 0, bufLength, Object(objNull)); - parser = new Parser(xref, memStream, true); + Parser *parser = new Parser(xref, memStream, true); int num, gen; Object obj; @@ -234,9 +239,11 @@ void Hints::readTables(BaseStream *str, Linearization *linearization, XRef *xref } } else { error(errSyntaxWarning, -1, "Invalid shared object hint table offset"); + ok = false; } } else { error(errSyntaxWarning, -1, "Failed parsing hints table object"); + ok = false; } delete parser; |