From: Mikko Rasa Date: Mon, 27 Dec 2021 23:05:20 +0000 (+0200) Subject: Require buffer to have storage for mapping X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=be962824e72a7d5e2946ad4c0e69e01c60da30e8;p=libs%2Fgl.git Require buffer to have storage for mapping --- diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index d5fc29d1..36ac440a 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -58,7 +58,7 @@ void Buffer::require_size(size_t req_sz) const void *Buffer::map() { - if(!can_map() || mapped) + if(size==0 || !can_map() || mapped) throw invalid_operation("Buffer::map"); void *result = BufferBackend::map(); mapped = true; @@ -67,8 +67,8 @@ void *Buffer::map() bool Buffer::unmap() { - if(!can_map() || !mapped) - throw invalid_operation("Buffer::map"); + if(size==0 || !can_map() || !mapped) + throw invalid_operation("Buffer::unmap"); bool result = BufferBackend::unmap(); mapped = false; return result;