diff options
author | Jay Berkenbilt <ejb@ql.org> | 2019-06-22 20:24:49 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2019-06-22 22:57:52 +0200 |
commit | 6c39aa87638f7a6f96a97627ac112fb2022bd3a7 (patch) | |
tree | 6941498e1cacbd6dcade4a695b27085fa693984f /libqpdf/ClosedFileInputSource.cc | |
parent | 12400475283f5081ea55f52a764e43f14032f6ba (diff) | |
download | qpdf-6c39aa87638f7a6f96a97627ac112fb2022bd3a7.tar.zst |
In shippable code, favor smart pointers (fixes #235)
Use PointerHolder in several places where manually memory allocation
and deallocation were being used. This helps to protect against memory
leaks when exceptions are thrown in surprising places.
Diffstat (limited to 'libqpdf/ClosedFileInputSource.cc')
-rw-r--r-- | libqpdf/ClosedFileInputSource.cc | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/libqpdf/ClosedFileInputSource.cc b/libqpdf/ClosedFileInputSource.cc index e9c9b3bd..f68a9a31 100644 --- a/libqpdf/ClosedFileInputSource.cc +++ b/libqpdf/ClosedFileInputSource.cc @@ -4,14 +4,12 @@ ClosedFileInputSource::Members::Members(char const* filename) : filename(filename), offset(0), - fis(0), stay_open(false) { } ClosedFileInputSource::Members::~Members() { - delete fis; } ClosedFileInputSource::ClosedFileInputSource(char const* filename) : @@ -26,7 +24,7 @@ ClosedFileInputSource::~ClosedFileInputSource() void ClosedFileInputSource::before() { - if (0 == this->m->fis) + if (0 == this->m->fis.getPointer()) { this->m->fis = new FileInputSource(); this->m->fis->setFilename(this->m->filename.c_str()); @@ -44,7 +42,6 @@ ClosedFileInputSource::after() { return; } - delete this->m->fis; this->m->fis = 0; } @@ -84,7 +81,7 @@ void ClosedFileInputSource::rewind() { this->m->offset = 0; - if (this->m->fis) + if (this->m->fis.getPointer()) { this->m->fis->rewind(); } @@ -112,7 +109,7 @@ void ClosedFileInputSource::stayOpen(bool val) { this->m->stay_open = val; - if ((! val) && this->m->fis) + if ((! val) && this->m->fis.getPointer()) { after(); } |