From ca1fc859f27560c7988f078cff89f40f1b6e2c0f Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Thu, 4 Aug 2011 21:51:29 +0200 Subject: Fixed memory leak caused by exceptions in HTTP::Connection::send_file(). --- http_connection.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/http_connection.cpp b/http_connection.cpp index 61928d3..4411a92 100644 --- a/http_connection.cpp +++ b/http_connection.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -104,10 +105,9 @@ void HTTP::Connection::send_file(const fs::path& filename) { is.seekg(begin); - char* buf = new char[end - begin]; - is.read(buf, end - begin); - send_data(buf, is.gcount()); - delete buf; + boost::scoped_array buf(new char[end-begin]); + is.read(buf.get(), end - begin); + send_data(buf.get(), is.gcount()); } else { add_header("Content-Length", boost::str(boost::format("%d") % length)); -- cgit v1.2.3