From bc0c0484745c8849b093ecccf1d9ca1636688567 Mon Sep 17 00:00:00 2001 From: "[CST] Bas" Date: Sun, 22 Feb 2015 23:26:16 +0800 Subject: [PATCH] src/driver/framebuffer.cpp: check dimension in int_convertRGB2FB and if it's not valid, spit out a warning and return NULL. --- src/driver/framebuffer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index 24bc2a527..6060ddb39 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -1825,7 +1825,15 @@ void * CFrameBuffer::int_convertRGB2FB(unsigned char *rgbbuff, unsigned long x, { unsigned long i; unsigned int *fbbuff; - unsigned long count = x * y; + unsigned long count; + + if (!x || !y) { + printf("convertRGB2FB%s: Error: invalid dimensions (%luX x %luY)\n", + ((alpha) ? " (Alpha)" : ""), x, y); + return NULL; + } + + count = x * y; fbbuff = (unsigned int *) cs_malloc_uncached(count * sizeof(unsigned int)); if(fbbuff == NULL) {