diff options
author | Even Rouault <even.rouault@mines-paris.org> | 2012-12-28 00:30:13 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2012-12-28 00:30:13 +0100 |
commit | 2017dbebd9afd4f172242ff8462fce739d911e64 (patch) | |
tree | 07507f5ca69948ae9621b28a458c2521f0452aed | |
parent | 858df0dc04e2f306e806fe0fc4fb5c8ec804e263 (diff) |
Do not crash on 0 or negative nBits values
-rw-r--r-- | poppler/Stream.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/poppler/Stream.cc b/poppler/Stream.cc index 842f0c62..414ff3fe 100644 --- a/poppler/Stream.cc +++ b/poppler/Stream.cc @@ -26,6 +26,7 @@ // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012 Oliver Sander <sander@mi.fu-berlin.de> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> +// Copyright (C) 2012 Even Rouault <even.rouault@mines-paris.org> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -419,11 +420,11 @@ ImageStream::ImageStream(Stream *strA, int widthA, int nCompsA, int nBitsA) { nVals = width * nComps; inputLineSize = (nVals * nBits + 7) >> 3; - if (nVals > INT_MAX / nBits - 7) { + if (nBits <= 0 || nVals > INT_MAX / nBits - 7) { // force a call to gmallocn(-1,...), which will throw an exception inputLineSize = -1; } - inputLine = (Guchar *)gmallocn(inputLineSize, sizeof(char)); + inputLine = (Guchar *)gmallocn_checkoverflow(inputLineSize, sizeof(char)); if (nBits == 8) { imgLine = (Guchar *)inputLine; } else { |