From be962824e72a7d5e2946ad4c0e69e01c60da30e8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 28 Dec 2021 01:05:20 +0200 Subject: [PATCH] Require buffer to have storage for mapping --- source/core/buffer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; -- 2.43.0