aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-08-12 18:58:39 +0200
committerJay Berkenbilt <ejb@ql.org>2018-08-12 18:58:39 +0200
commitb6e414b10b3ae7b28ad16da2027106ec59a99a0a (patch)
treececd3bb38d43af6d4fa687414d2565e71c0ac206 /libqpdf
parent4a4736c6954ab17d923a6d2968f34a33e09d714f (diff)
downloadqpdf-b6e414b10b3ae7b28ad16da2027106ec59a99a0a.tar.zst
Remove some extraneous null pointer checks (fixes #234)
There were a few places in the code that were checking that a pointer wasn't null before deleting it, even though C++ has always allowed delete 0. Most of the code did not perform these checks.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/ClosedFileInputSource.cc5
-rw-r--r--libqpdf/Pl_Flate.cc7
-rw-r--r--libqpdf/Pl_RC4.cc14
-rw-r--r--libqpdf/QPDFWriter.cc5
4 files changed, 8 insertions, 23 deletions
diff --git a/libqpdf/ClosedFileInputSource.cc b/libqpdf/ClosedFileInputSource.cc
index 63357886..e9c9b3bd 100644
--- a/libqpdf/ClosedFileInputSource.cc
+++ b/libqpdf/ClosedFileInputSource.cc
@@ -11,10 +11,7 @@ ClosedFileInputSource::Members::Members(char const* filename) :
ClosedFileInputSource::Members::~Members()
{
- if (fis)
- {
- delete fis;
- }
+ delete fis;
}
ClosedFileInputSource::ClosedFileInputSource(char const* filename) :
diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc
index 3becc135..4cd48046 100644
--- a/libqpdf/Pl_Flate.cc
+++ b/libqpdf/Pl_Flate.cc
@@ -31,11 +31,8 @@ Pl_Flate::Pl_Flate(char const* identifier, Pipeline* next,
Pl_Flate::~Pl_Flate()
{
- if (this->outbuf)
- {
- delete [] this->outbuf;
- this->outbuf = 0;
- }
+ delete [] this->outbuf;
+ this->outbuf = 0;
if (this->initialized)
{
diff --git a/libqpdf/Pl_RC4.cc b/libqpdf/Pl_RC4.cc
index 87c17f83..407490ca 100644
--- a/libqpdf/Pl_RC4.cc
+++ b/libqpdf/Pl_RC4.cc
@@ -13,11 +13,8 @@ Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next,
Pl_RC4::~Pl_RC4()
{
- if (this->outbuf)
- {
- delete [] this->outbuf;
- this->outbuf = 0;
- }
+ delete [] this->outbuf;
+ this->outbuf = 0;
}
void
@@ -47,10 +44,7 @@ Pl_RC4::write(unsigned char* data, size_t len)
void
Pl_RC4::finish()
{
- if (this->outbuf)
- {
- delete [] this->outbuf;
- this->outbuf = 0;
- }
+ delete [] this->outbuf;
+ this->outbuf = 0;
this->getNext()->finish();
}
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index 30ba6f1f..71c48333 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -75,10 +75,7 @@ QPDFWriter::Members::~Members()
{
fclose(file);
}
- if (output_buffer)
- {
- delete output_buffer;
- }
+ delete output_buffer;
}
QPDFWriter::QPDFWriter(QPDF& pdf) :