mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
bleh this one should work
This commit is contained in:
@@ -39,28 +39,18 @@ int RErrorCode=RERR_NONE;
|
|||||||
#define HAS_ALPHA(I) ((I)->format == RRGBAFormat)
|
#define HAS_ALPHA(I) ((I)->format == RRGBAFormat)
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_WIDTH 30000
|
||||||
|
#define MAX_HEIGHT 30000
|
||||||
|
|
||||||
|
|
||||||
RImage*
|
RImage*
|
||||||
RCreateImage(unsigned width, unsigned height, int alpha)
|
RCreateImage(unsigned width, unsigned height, int alpha)
|
||||||
{
|
{
|
||||||
RImage *image=NULL;
|
RImage *image=NULL;
|
||||||
unsigned bla1, bla2;
|
|
||||||
|
|
||||||
assert(width>0 && height>0);
|
assert(width>0 && height>0);
|
||||||
|
|
||||||
/* detect overflow (gr33tz to ruda :D) */
|
if (width > MAX_WIDTH || height > MAX_HEIGHT) {
|
||||||
bla1 = width*height;
|
|
||||||
if (bla1 / height != width) {
|
|
||||||
RErrorCode = RERR_NOMEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bla2 = bla1*4;
|
|
||||||
if (bla2/4 != bla1) {
|
|
||||||
RErrorCode = RERR_NOMEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bla2 > INT_MAX - 4) {
|
|
||||||
RErrorCode = RERR_NOMEMORY;
|
RErrorCode = RERR_NOMEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user