aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/ClosedFileInputSource.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-06-22 20:24:49 +0200
committerJay Berkenbilt <ejb@ql.org>2019-06-22 22:57:52 +0200
commit6c39aa87638f7a6f96a97627ac112fb2022bd3a7 (patch)
tree6941498e1cacbd6dcade4a695b27085fa693984f /libqpdf/ClosedFileInputSource.cc
parent12400475283f5081ea55f52a764e43f14032f6ba (diff)
downloadqpdf-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.cc9
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();
}