aboutsummaryrefslogtreecommitdiff
path: root/backends/vkeybd
diff options
context:
space:
mode:
authorJulien2011-06-04 06:46:40 +0800
committerJulien2011-06-23 15:11:36 +0800
commitc52cc849123ac4a6e4a6ce1f0880cb1cd95e23cd (patch)
tree57cbaaf240bd1177f6bf36257b55882508b1e88f /backends/vkeybd
parent2f200ac49322ff8ccd13c5e8b7a22abbf6ff2610 (diff)
downloadscummvm-rg350-c52cc849123ac4a6e4a6ce1f0880cb1cd95e23cd.tar.gz
scummvm-rg350-c52cc849123ac4a6e4a6ce1f0880cb1cd95e23cd.tar.bz2
scummvm-rg350-c52cc849123ac4a6e4a6ce1f0880cb1cd95e23cd.zip
AUDIO/BACKENDS/GRAPHICS: Add error checks after allocating memory with malloc
Diffstat (limited to 'backends/vkeybd')
-rw-r--r--backends/vkeybd/virtual-keyboard-parser.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp
index 5e4ce11fe4..58f0c468f6 100644
--- a/backends/vkeybd/virtual-keyboard-parser.cpp
+++ b/backends/vkeybd/virtual-keyboard-parser.cpp
@@ -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;