mirror of https://github.com/mgba-emu/mgba.git
Util: Reject 0-width/height images
This commit is contained in:
parent
6d719b529a
commit
285f22927b
|
@ -14,6 +14,9 @@
|
|||
#define ROW(IM, Y) PIXEL(IM, 0, Y)
|
||||
|
||||
struct mImage* mImageCreate(unsigned width, unsigned height, enum mColorFormat format) {
|
||||
if (width < 1 || height < 1) {
|
||||
return NULL;
|
||||
}
|
||||
struct mImage* image = calloc(1, sizeof(struct mImage));
|
||||
if (!image) {
|
||||
return NULL;
|
||||
|
|
|
@ -11,6 +11,15 @@
|
|||
#endif
|
||||
#include <mgba-util/vfs.h>
|
||||
|
||||
M_TEST_DEFINE(zeroDim) {
|
||||
assert_null(mImageCreate(0, 0, mCOLOR_ABGR8));
|
||||
assert_null(mImageCreate(1, 0, mCOLOR_ABGR8));
|
||||
assert_null(mImageCreate(0, 1, mCOLOR_ABGR8));
|
||||
struct mImage* image = mImageCreate(1, 1, mCOLOR_ABGR8);
|
||||
assert_non_null(image);
|
||||
mImageDestroy(image);
|
||||
}
|
||||
|
||||
M_TEST_DEFINE(pitchRead) {
|
||||
static uint8_t buffer[12] = {
|
||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB
|
||||
|
@ -695,6 +704,7 @@ M_TEST_DEFINE(convert2x2) {
|
|||
}
|
||||
|
||||
M_TEST_SUITE_DEFINE(Image,
|
||||
cmocka_unit_test(zeroDim),
|
||||
cmocka_unit_test(pitchRead),
|
||||
cmocka_unit_test(strideRead),
|
||||
cmocka_unit_test(oobRead),
|
||||
|
|
Loading…
Reference in New Issue