Commit b6e414b10b3ae7b28ad16da2027106ec59a99a0a

Authored by Jay Berkenbilt
1 parent 4a4736c6

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.
libqpdf/ClosedFileInputSource.cc
... ... @@ -11,10 +11,7 @@ ClosedFileInputSource::Members::Members(char const* filename) :
11 11  
12 12 ClosedFileInputSource::Members::~Members()
13 13 {
14   - if (fis)
15   - {
16   - delete fis;
17   - }
  14 + delete fis;
18 15 }
19 16  
20 17 ClosedFileInputSource::ClosedFileInputSource(char const* filename) :
... ...
libqpdf/Pl_Flate.cc
... ... @@ -31,11 +31,8 @@ Pl_Flate::Pl_Flate(char const* identifier, Pipeline* next,
31 31  
32 32 Pl_Flate::~Pl_Flate()
33 33 {
34   - if (this->outbuf)
35   - {
36   - delete [] this->outbuf;
37   - this->outbuf = 0;
38   - }
  34 + delete [] this->outbuf;
  35 + this->outbuf = 0;
39 36  
40 37 if (this->initialized)
41 38 {
... ...
libqpdf/Pl_RC4.cc
... ... @@ -13,11 +13,8 @@ Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next,
13 13  
14 14 Pl_RC4::~Pl_RC4()
15 15 {
16   - if (this->outbuf)
17   - {
18   - delete [] this->outbuf;
19   - this->outbuf = 0;
20   - }
  16 + delete [] this->outbuf;
  17 + this->outbuf = 0;
21 18 }
22 19  
23 20 void
... ... @@ -47,10 +44,7 @@ Pl_RC4::write(unsigned char* data, size_t len)
47 44 void
48 45 Pl_RC4::finish()
49 46 {
50   - if (this->outbuf)
51   - {
52   - delete [] this->outbuf;
53   - this->outbuf = 0;
54   - }
  47 + delete [] this->outbuf;
  48 + this->outbuf = 0;
55 49 this->getNext()->finish();
56 50 }
... ...
libqpdf/QPDFWriter.cc
... ... @@ -75,10 +75,7 @@ QPDFWriter::Members::~Members()
75 75 {
76 76 fclose(file);
77 77 }
78   - if (output_buffer)
79   - {
80   - delete output_buffer;
81   - }
  78 + delete output_buffer;
82 79 }
83 80  
84 81 QPDFWriter::QPDFWriter(QPDF& pdf) :
... ...