diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-26 17:36:17 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-26 17:37:13 +0200 |
commit | 99637fb4c69ad7f136acc69c2fc0a46f57b9ce67 (patch) | |
tree | 6cc68a3b84468da995c7725df2513411c5ec6cca /shell | |
parent | 3427e613c68fefd0464cb1f9806deb55ca1c3661 (diff) |
loplugin:useuniqueptr (clang-cl)
Change-Id: Ie541ecc3ec8d7032666b09aaec7d216a43ae44f1
Diffstat (limited to 'shell')
-rw-r--r-- | shell/source/win32/zipfile/zipfile.cxx | 9 |
1 files changed, 4 insertions, 5 deletions
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 <malloc.h> #include <algorithm> #include <functional> +#include <memory> #include <string.h> @@ -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<unsigned char[]>(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<char *>(tmp), size); - delete [] tmp; + std::string aStr(reinterpret_cast<char *>(tmp.get()), size); return aStr; } |