]> git.tdb.fi Git - libs/gl.git/commitdiff
Require buffer to have storage for mapping
authorMikko Rasa <tdb@tdb.fi>
Mon, 27 Dec 2021 23:05:20 +0000 (01:05 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 27 Dec 2021 23:05:20 +0000 (01:05 +0200)
source/core/buffer.cpp

index d5fc29d11635830042b1b065905c818c1d3ac79d..36ac440a54426c186c16ae238c51a337312445e8 100644 (file)
@@ -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;