aboutsummaryrefslogtreecommitdiffstats
path: root/zlib-flate/zlib-flate.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 /zlib-flate/zlib-flate.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 'zlib-flate/zlib-flate.cc')
-rw-r--r--zlib-flate/zlib-flate.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/zlib-flate/zlib-flate.cc b/zlib-flate/zlib-flate.cc
index 9d4a62e2..d1c74d4d 100644
--- a/zlib-flate/zlib-flate.cc
+++ b/zlib-flate/zlib-flate.cc
@@ -61,8 +61,9 @@ int main(int argc, char* argv[])
QUtil::binary_stdout();
QUtil::binary_stdin();
- Pl_StdioFile* out = new Pl_StdioFile("stdout", stdout);
- Pl_Flate* flate = new Pl_Flate("flate", out, action);
+ PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("stdout", stdout);
+ PointerHolder<Pl_Flate> flate =
+ new Pl_Flate("flate", out.getPointer(), action);
try
{
@@ -81,8 +82,6 @@ int main(int argc, char* argv[])
}
}
flate->finish();
- delete flate;
- delete out;
}
catch (std::exception& e)
{