mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 06:41:51 +00:00
AUDIO/BACKENDS/GRAPHICS: Add error checks after allocating memory with malloc
This commit is contained in:
parent
2f200ac493
commit
c52cc84912
@ -298,6 +298,9 @@ public:
|
||||
_bufferSize = osamp;
|
||||
}
|
||||
|
||||
if (!_buffer)
|
||||
error("[CopyRateConverter::flow] Cannot allocate memory for temp buffer");
|
||||
|
||||
// Read up to 'osamp' samples into our temporary buffer
|
||||
len = input.readBuffer(_buffer, osamp);
|
||||
|
||||
|
@ -725,6 +725,8 @@ static int OPLOpenTable(void) {
|
||||
|
||||
|
||||
ENV_CURVE = (int *)malloc(sizeof(int) * (2*EG_ENT+1));
|
||||
if (!ENV_CURVE)
|
||||
error("[OPLOpenTable] Cannot allocate memory");
|
||||
|
||||
/* envelope counter -> envelope output table */
|
||||
for (i=0; i < EG_ENT; i++) {
|
||||
|
@ -205,6 +205,9 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) {
|
||||
|
||||
evt->type = VirtualKeyboard::kVKEventModifier;
|
||||
byte *flags = (byte*) malloc(sizeof(byte));
|
||||
if (!flags)
|
||||
error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory");
|
||||
|
||||
*(flags) = parseFlags(node->values["modifiers"]);
|
||||
evt->data = flags;
|
||||
|
||||
@ -217,6 +220,9 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) {
|
||||
evt->type = VirtualKeyboard::kVKEventSwitchMode;
|
||||
String& mode = node->values["mode"];
|
||||
char *str = (char*) malloc(sizeof(char) * mode.size() + 1);
|
||||
if (!str)
|
||||
error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory");
|
||||
|
||||
memcpy(str, mode.c_str(), sizeof(char) * mode.size());
|
||||
str[mode.size()] = 0;
|
||||
evt->data = str;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user