mm_util_error("Gif File wrong decode parameters");
return MM_UTIL_ERROR_INVALID_OPERATION;
}
-
+ if (GifFile->SWidth <= 0 || GifFile->SHeight <= 0) {
+ mm_util_error("Gif File wrong decode width & height");
+ return MM_UTIL_ERROR_INVALID_OPERATION;
+ }
decoded->width = GifFile->SWidth;
decoded->height = GifFile->SHeight;
decoded->size = (unsigned long long)GifFile->SWidth * (unsigned long long)GifFile->SHeight * 4;
}
Size = GifFile->SWidth * sizeof(GifPixelType); /* Size in bytes one row. */
- if ((screen_buffer[0] = (GifRowType) malloc(Size)) == NULL) { /* First row. */
+ if ((screen_buffer[0] = (GifRowType) calloc(1, Size)) == NULL) { /* First row. */
mm_util_error("Failed to allocate memory required, aborted.");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
goto error;
screen_buffer[0][i] = GifFile->SBackGroundColor;
for (i = 1; i < GifFile->SHeight; i++) {
/* Allocate the other rows, and set their color to background too: */
- if ((screen_buffer[i] = (GifRowType) malloc(Size)) == NULL) {
+ if ((screen_buffer[i] = (GifRowType) calloc(1, Size)) == NULL) {
mm_util_error("Failed to allocate memory required, aborted.");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
goto error;
ret = MM_UTIL_ERROR_INVALID_OPERATION;
goto error;
}
+ if (GifFile->Image.Top < 0 || GifFile->Image.Left < 0 || GifFile->Image.Width <= 0 || GifFile->Image.Height <= 0) {
+ mm_util_error("Gif File wrong decode width & height");
+ ret = MM_UTIL_ERROR_INVALID_OPERATION;
+ goto error;
+ }
Row = GifFile->Image.Top; /* Image Position relative to Screen. */
Col = GifFile->Image.Left;
Width = GifFile->Image.Width;