AUDIO/BACKENDS/GRAPHICS: Add error checks after allocating memory with malloc

This commit is contained in:
Julien 2011-06-04 06:46:40 +08:00 committed by Julien
parent 2f200ac493
commit c52cc84912
4 changed files with 15 additions and 0 deletions

View file

@ -24,6 +24,7 @@
#include "graphics/scaler/scalebit.h"
#include "common/util.h"
#include "common/system.h"
#include "common/textconsole.h"
int gBitFormat = 565;
@ -90,6 +91,9 @@ void InitLUT(Graphics::PixelFormat format) {
if (RGBtoYUV == 0)
RGBtoYUV = (uint32 *)malloc(65536 * sizeof(uint32));
if (!RGBtoYUV)
error("[InitLUT] Cannot allocate memory for YUV/LUT buffers");
for (int color = 0; color < 65536; ++color) {
format.colorToRGB(color, r, g, b);
Y = (r + g + b) >> 2;