summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2019-10-18 20:35:53 -0400
committer AJR <ajrhacker@users.noreply.github.com>2019-10-18 20:36:22 -0400
commitdd46572f6db798b7dce9bac74be29046377b37a7 (patch)
treef86fdf954e2db9054759ad7bdd929fb25d77f9ac /src
parentd991043cea16edc82d205b8b655bef5316fb4dc8 (diff)
sprite: Add some sanity checks (nw)
Diffstat (limited to 'src')
-rw-r--r--src/devices/video/sprite.cpp4
-rw-r--r--src/devices/video/sprite.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/devices/video/sprite.cpp b/src/devices/video/sprite.cpp
index 32911a7bc18..de62b3fea7d 100644
--- a/src/devices/video/sprite.cpp
+++ b/src/devices/video/sprite.cpp
@@ -98,7 +98,7 @@ sparse_dirty_rect *sparse_dirty_bitmap::first_dirty_rect(const rectangle &clipre
{
// if what we have is valid, just return it again
if (m_rect_list_bounds == cliprect)
- return m_rect_list.first();
+ return m_rect_list.empty() ? nullptr : m_rect_list.first();
// reclaim the dirty list and start over
m_rect_allocator.reclaim_all(m_rect_list);
@@ -153,5 +153,5 @@ sparse_dirty_rect *sparse_dirty_bitmap::first_dirty_rect(const rectangle &clipre
// mark the list as valid
m_rect_list_bounds = cliprect;
- return m_rect_list.first();
+ return m_rect_list.empty() ? nullptr : m_rect_list.first();
}
diff --git a/src/devices/video/sprite.h b/src/devices/video/sprite.h
index 93cd38190a6..2ef3234b9d9 100644
--- a/src/devices/video/sprite.h
+++ b/src/devices/video/sprite.h
@@ -105,13 +105,13 @@ public:
_SpriteRAMType *buffer() { return &m_buffer[0]; }
// configuration
- void set_spriteram(_SpriteRAMType *base, uint32_t bytes) { m_spriteram = base; m_spriteram_bytes = bytes; m_buffer.resize(m_spriteram_bytes / sizeof(_SpriteRAMType)); }
+ void set_spriteram(_SpriteRAMType *base, uint32_t bytes) { assert(base != nullptr && bytes != 0); m_spriteram = base; m_spriteram_bytes = bytes; m_buffer.resize(m_spriteram_bytes / sizeof(_SpriteRAMType)); }
void set_origin(int32_t xorigin = 0, int32_t yorigin = 0) { m_xorigin = xorigin; m_yorigin = yorigin; }
void set_xorigin(int32_t xorigin) { m_xorigin = xorigin; }
void set_yorigin(int32_t yorigin) { m_yorigin = yorigin; }
// buffering
- void copy_to_buffer() { memcpy(m_buffer, m_spriteram, m_spriteram_bytes); }
+ void copy_to_buffer() { assert(m_spriteram != nullptr); memcpy(m_buffer, m_spriteram, m_spriteram_bytes); }
// clearing
void clear() { clear(m_bitmap.cliprect()); }