Remove extra whitespace, add size checks

This commit is contained in:
2025-08-13 16:33:58 +03:00
parent d05efc5f85
commit dd63b19f71
2 changed files with 21 additions and 13 deletions

View File

@@ -429,6 +429,8 @@ BH_Bitmap *BH_BitmapNew(uint32_t width,
/* Get format information */ /* Get format information */
formatInfo = formats + (format & 0x0FFF); formatInfo = formats + (format & 0x0FFF);
if ((format & 0x0FFF) > sizeof(formats) / sizeof(FormatInfo))
return NULL;
/* Unset internal flags */ /* Unset internal flags */
flags &= ~BH_BITMAP_FLAG_EXT_DATA; flags &= ~BH_BITMAP_FLAG_EXT_DATA;
@@ -674,6 +676,12 @@ void BH_BitmapConvertRow(void *src,
srcInfo = formats + (srcFormat & 0x0FFF); srcInfo = formats + (srcFormat & 0x0FFF);
destInfo = formats + (destFormat & 0x0FFF); destInfo = formats + (destFormat & 0x0FFF);
if ((srcFormat & 0x0FFF) > sizeof(formats) / sizeof(FormatInfo))
return;
if ((destFormat & 0x0FFF) > sizeof(formats) / sizeof(FormatInfo))
return;
for (x = 0; count; --count, ++x) for (x = 0; count; --count, ++x)
{ {
void *srcAt, *destAt; void *srcAt, *destAt;