From 99637fb4c69ad7f136acc69c2fc0a46f57b9ce67 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 26 Apr 2017 17:36:17 +0200 Subject: loplugin:useuniqueptr (clang-cl) Change-Id: Ie541ecc3ec8d7032666b09aaec7d216a43ae44f1 --- shell/source/win32/zipfile/zipfile.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'shell') diff --git a/shell/source/win32/zipfile/zipfile.cxx b/shell/source/win32/zipfile/zipfile.cxx index a65fe32248a6..d33500735977 100644 --- a/shell/source/win32/zipfile/zipfile.cxx +++ b/shell/source/win32/zipfile/zipfile.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -130,16 +131,14 @@ std::string readString(StreamInterface *stream, unsigned long size) { if (!stream || stream->stell() == -1) throw IOException(-1); - unsigned char *tmp = new unsigned char[size]; - unsigned long numBytesRead = stream->sread(tmp, size); + auto tmp = std::unique_ptr(new unsigned char[size]); + unsigned long numBytesRead = stream->sread(tmp.get(), size); if (numBytesRead != size) { - delete [] tmp; throw IOException(-1); } - std::string aStr(reinterpret_cast(tmp), size); - delete [] tmp; + std::string aStr(reinterpret_cast(tmp.get()), size); return aStr; } -- cgit