Add input checks, fix overflow/wrap related bugs

This commit is contained in:
2025-08-04 20:35:19 +03:00
parent deb4ec00f4
commit 4ce443f0d9
4 changed files with 137 additions and 113 deletions

View File

@@ -113,8 +113,8 @@ I<BH_BITMAP_RGBA32> pixel format.
=head2 BH_BitmapNew
BH_Bitmap *BH_BitmapNew(int width,
int height,
BH_Bitmap *BH_BitmapNew(uint32_t width,
uint32_t height,
int format,
int flags,
void *data,
@@ -149,8 +149,8 @@ Destroys the bitmap object.
=head2 BH_BitmapColor
void BH_BitmapColor(const BH_Bitmap *bitmap,
int x,
int y,
uint32_t x,
uint32_t y,
BH_Color *value);
Reads color value of the pixel at specified position.
@@ -161,8 +161,8 @@ The I<x> and I<y> parameters specify a position on the bitmap.
=head2 BH_BitmapSetColor
void BH_BitmapSetColor(BH_Bitmap *bitmap,
int x,
int y,
uint32_t x,
uint32_t y,
const BH_Color *value);
Writes color value of the pixel at specified position.
@@ -173,8 +173,8 @@ The I<x> and I<y> parameters specify a position on the bitmap.
=head2 BH_BitmapIndex
uint8_t BH_BitmapIndex(const BH_Bitmap *bitmap,
int x,
int y);
uint32_t x,
uint32_t y);
Returns the index value at the specified position.
@@ -184,8 +184,8 @@ The I<x> and I<y> parameters specify a position on the bitmap.
=head2 BH_BitmapSetIndex
void BH_BitmapSetIndex(BH_Bitmap *bitmap,
int x,
int y,
uint32_t x,
uint32_t y,
uint8_t index);
Sets the index value at the specified position.
@@ -196,10 +196,10 @@ The I<x> and I<y> parameters specify a position on the bitmap.
=head2 BH_BitmapCopy
BH_Bitmap *BH_BitmapCopy(BH_Bitmap *bitmap,
int x,
int y,
int width,
int height,
uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height,
int shallow);
Creates a copy of the bitmap region by the given position and size.
@@ -218,7 +218,7 @@ This function returns a pointer to a new BH_Bitmap object or NULL.
=head2 BH_BitmapScanline
void *BH_BitmapScanline(const BH_Bitmap *bitmap,
int y);
uint32_t y);
Returns address of the scanline in the bitmap.
@@ -226,22 +226,22 @@ Returns address of the scanline in the bitmap.
=head2 BH_BitmapAt
void *BH_BitmapAt(const BH_Bitmap *bitmap,
int x,
int y);
uint32_t x,
uint32_t y);
Returns address of the pixel in the bitmap.
=head2 BH_BitmapWidth
int BH_BitmapWidth(BH_Bitmap *bitmap);
uint32_t BH_BitmapWidth(BH_Bitmap *bitmap);
Returns width of the bitmap.
=head2 BH_BitmapHeight
int BH_BitmapHeight(BH_Bitmap *bitmap);
uint32_t BH_BitmapHeight(BH_Bitmap *bitmap);
Returns height of the bitmap.