From ddede5e4132e88ef0e1f6e8b1e6a6f6fb281f770 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Mon, 8 Oct 2012 10:24:20 +0000 Subject: [PATCH] + fix crash on MS/Windows with files having an empty title (Alchemy.zim) --- src/zimlib/src/cluster.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/zimlib/src/cluster.cpp b/src/zimlib/src/cluster.cpp index 73868a3..f040d8e 100644 --- a/src/zimlib/src/cluster.cpp +++ b/src/zimlib/src/cluster.cpp @@ -105,8 +105,11 @@ namespace zim { n = offsets.back() - offsets.front(); data.resize(n); - log_debug1("read " << n << " bytes of data"); - in.read(&(data[0]), n); + if (n > 0) + { + log_debug1("read " << n << " bytes of data"); + in.read(&(data[0]), n); + } } } @@ -133,7 +136,8 @@ namespace zim Blob ClusterImpl::getBlob(size_type n) const { - return Blob(const_cast(this), getData(n), getSize(n)); + return getSize(n) > 0 ? + Blob(const_cast(this), getData(n), getSize(n)) : Blob(); } void ClusterImpl::clear()