2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-27 15:43:33 +00:00

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.
This commit is contained in:
Jay Berkenbilt 2018-08-12 12:58:39 -04:00
parent 4a4736c695
commit b6e414b10b
4 changed files with 8 additions and 23 deletions

View File

@ -11,10 +11,7 @@ ClosedFileInputSource::Members::Members(char const* filename) :
ClosedFileInputSource::Members::~Members() ClosedFileInputSource::Members::~Members()
{ {
if (fis) delete fis;
{
delete fis;
}
} }
ClosedFileInputSource::ClosedFileInputSource(char const* filename) : ClosedFileInputSource::ClosedFileInputSource(char const* filename) :

View File

@ -31,11 +31,8 @@ Pl_Flate::Pl_Flate(char const* identifier, Pipeline* next,
Pl_Flate::~Pl_Flate() Pl_Flate::~Pl_Flate()
{ {
if (this->outbuf) delete [] this->outbuf;
{ this->outbuf = 0;
delete [] this->outbuf;
this->outbuf = 0;
}
if (this->initialized) if (this->initialized)
{ {

View File

@ -13,11 +13,8 @@ Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next,
Pl_RC4::~Pl_RC4() Pl_RC4::~Pl_RC4()
{ {
if (this->outbuf) delete [] this->outbuf;
{ this->outbuf = 0;
delete [] this->outbuf;
this->outbuf = 0;
}
} }
void void
@ -47,10 +44,7 @@ Pl_RC4::write(unsigned char* data, size_t len)
void void
Pl_RC4::finish() Pl_RC4::finish()
{ {
if (this->outbuf) delete [] this->outbuf;
{ this->outbuf = 0;
delete [] this->outbuf;
this->outbuf = 0;
}
this->getNext()->finish(); this->getNext()->finish();
} }

View File

@ -75,10 +75,7 @@ QPDFWriter::Members::~Members()
{ {
fclose(file); fclose(file);
} }
if (output_buffer) delete output_buffer;
{
delete output_buffer;
}
} }
QPDFWriter::QPDFWriter(QPDF& pdf) : QPDFWriter::QPDFWriter(QPDF& pdf) :