From 6c39aa87638f7a6f96a97627ac112fb2022bd3a7 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 22 Jun 2019 14:24:49 -0400 Subject: 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. --- zlib-flate/zlib-flate.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'zlib-flate') 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 out = new Pl_StdioFile("stdout", stdout); + PointerHolder 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) { -- cgit v1.2.3-54-g00ecf