From 0ded90eff979c0a329736861995b2516139de114 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 14 Sep 2009 01:31:46 +0000 Subject: [PATCH] fix problems or otherwise improve code based on issues raised by Klocwork git-svn-id: svn+q:///qpdf/trunk@690 71b93d88-0707-0410-a8cf-f5a4172ac649 --- libqpdf/PCRE.cc | 2 +- libqpdf/QPDF_linearization.cc | 20 +++++++++----------- libtests/flate.cc | 1 + libtests/png_filter.cc | 1 + 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libqpdf/PCRE.cc b/libqpdf/PCRE.cc index 59174f67..872fde36 100644 --- a/libqpdf/PCRE.cc +++ b/libqpdf/PCRE.cc @@ -147,7 +147,7 @@ PCRE::Match::nMatches() const return this->nmatches; } -PCRE::PCRE(char const* pattern, int options) throw (Exception) +PCRE::PCRE(char const* pattern, int options) throw (PCRE::Exception) { char const *errptr; int erroffset; diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index 2a81856e..281748b5 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -113,19 +113,17 @@ QPDF::isLinearized() } else { - if ((p = (char*)memchr(p, '\0', tbuf_size - (p - buf))) != 0) + p = (char*)memchr(p, '\0', tbuf_size - (p - buf)); + assert(p != 0); + while ((p - buf < tbuf_size) && (*p == 0)) { - QTC::TC("qpdf", "QPDF lindict null found"); - while ((p - buf < tbuf_size) && (*p == 0)) - { - ++p; - } - if ((p - buf) == tbuf_size) - { - break; - } - QTC::TC("qpdf", "QPDF lindict searching after null"); + ++p; } + if ((p - buf) == tbuf_size) + { + break; + } + QTC::TC("qpdf", "QPDF lindict searching after null"); } } diff --git a/libtests/flate.cc b/libtests/flate.cc index b6059a21..d05e7f92 100644 --- a/libtests/flate.cc +++ b/libtests/flate.cc @@ -15,6 +15,7 @@ FILE* safe_fopen(char const* filename, char const* mode) { std::cerr << "fopen " << filename << " failed: " << strerror(errno) << std::endl; + exit(2); } return result; } diff --git a/libtests/png_filter.cc b/libtests/png_filter.cc index 4a888bf9..a4b8a110 100644 --- a/libtests/png_filter.cc +++ b/libtests/png_filter.cc @@ -15,6 +15,7 @@ FILE* safe_fopen(char const* filename, char const* mode) { std::cerr << "fopen " << filename << " failed: " << strerror(errno) << std::endl; + exit(2); } return result; }