GRAPHICS: Make setPixel assert in attempts to draw outside of the surface

Based on PR#5011 by phcoder.

Expect some of your engines to fail during runtime, fix them.
This commit is contained in:
Eugene Sandulenko 2023-08-06 14:07:43 +02:00
parent c200890161
commit 9862969f69
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -181,6 +181,7 @@ public:
*/
inline void setPixel(int x, int y, int pixel) {
assert(format.bytesPerPixel > 0 && format.bytesPerPixel <= 4);
assert(x >= 0 && x < w && y >= 0 && y < h);
if (format.bytesPerPixel == 1)
*((uint8 *)getBasePtr(x, y)) = pixel;
else if (format.bytesPerPixel == 2)