From 0368e444af10db6b2e4e0a61d652a8246dafbf60 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 17 Oct 2008 01:46:06 +0000 Subject: [PATCH] fix to torrent_info constructor to not try to access 0 pointer when loading a 0 size torrent file --- src/torrent_info.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index e6f4e75f5..321e75aca 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -319,6 +319,13 @@ namespace libtorrent int ret = load_file(filename, buf); if (ret < 0) return; + if (buf.empty()) +#ifndef BOOST_NO_EXCEPTIONS + throw invalid_torrent_file(); +#else + return; +#endif + lazy_entry e; lazy_bdecode(&buf[0], &buf[0] + buf.size(), e); std::string error;