From 55d8b0625fa4aa34e0debefb1881a5a3ae3c000f Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 28 Jun 2016 08:43:31 -0400 Subject: [PATCH] fix --- include/libtorrent/stack_allocator.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/libtorrent/stack_allocator.hpp b/include/libtorrent/stack_allocator.hpp index cfe084acf..926d8d46e 100644 --- a/include/libtorrent/stack_allocator.hpp +++ b/include/libtorrent/stack_allocator.hpp @@ -77,7 +77,10 @@ namespace libtorrent { namespace aux #pragma clang diagnostic pop #endif - m_storage.resize(len > 512 ? 512 : len); + if (len < 0) return copy_string("(format error)"); + + // +1 is to include the 0-terminator + m_storage.resize(ret + (len > 512 ? 512 : len) + 1); return ret; }