diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 4d179218f78..f633967697c 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -881,7 +881,8 @@ std::error_code copy_file(const Twine &From, const Twine &To) { } const size_t BufSize = 4096; - char *Buf = new char[BufSize]; + std::vector Buffer(BufSize); + char *Buf = Buffer.data(); int BytesRead = 0, BytesWritten = 0; for (;;) { BytesRead = read(ReadFD, Buf, BufSize); @@ -898,7 +899,6 @@ std::error_code copy_file(const Twine &From, const Twine &To) { } close(ReadFD); close(WriteFD); - delete[] Buf; if (BytesRead < 0 || BytesWritten < 0) return std::error_code(errno, std::generic_category());