From 1f5b9c618577ea1424ac83c4cac37231d334382d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 22 Feb 2016 17:50:15 +0100 Subject: [PATCH] tag/ApeLoader: use std::unique_ptr --- src/tag/ApeLoader.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx index 26d42c48b..3488230a7 100644 --- a/src/tag/ApeLoader.cxx +++ b/src/tag/ApeLoader.cxx @@ -28,6 +28,8 @@ #include "util/StringView.hxx" #include "util/Error.hxx" +#include + #include #include #include @@ -69,15 +71,13 @@ tag_ape_scan(InputStream &is, ApeTagCallback callback) remaining -= sizeof(footer); assert(remaining > 10); - char *buffer = new char[remaining]; - if (!is.ReadFull(buffer, remaining, IgnoreError())) { - delete[] buffer; + std::unique_ptr buffer(new char[remaining]); + if (!is.ReadFull(buffer.get(), remaining, IgnoreError())) return false; - } /* read tags */ unsigned n = FromLE32(footer.count); - const char *p = buffer; + const char *p = buffer.get(); while (n-- && remaining > 10) { size_t size = FromLE32(*(const uint32_t *)p); p += 4; @@ -106,7 +106,6 @@ tag_ape_scan(InputStream &is, ApeTagCallback callback) remaining -= size; } - delete[] buffer; return true; }