summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-04-26 17:36:17 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-04-26 17:37:13 +0200
commit99637fb4c69ad7f136acc69c2fc0a46f57b9ce67 (patch)
tree6cc68a3b84468da995c7725df2513411c5ec6cca /shell
parent3427e613c68fefd0464cb1f9806deb55ca1c3661 (diff)
loplugin:useuniqueptr (clang-cl)
Change-Id: Ie541ecc3ec8d7032666b09aaec7d216a43ae44f1
Diffstat (limited to 'shell')
-rw-r--r--shell/source/win32/zipfile/zipfile.cxx9
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;
}