From c52cc849123ac4a6e4a6ce1f0880cb1cd95e23cd Mon Sep 17 00:00:00 2001
From: Julien
Date: Sat, 4 Jun 2011 06:46:40 +0800
Subject: AUDIO/BACKENDS/GRAPHICS: Add error checks after allocating memory
 with malloc

---
 audio/rate.cpp               | 3 +++
 audio/softsynth/opl/mame.cpp | 2 ++
 2 files changed, 5 insertions(+)

(limited to 'audio')

diff --git a/audio/rate.cpp b/audio/rate.cpp
index 83abd6150b..0fc23a8a54 100644
--- a/audio/rate.cpp
+++ b/audio/rate.cpp
@@ -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);
 
diff --git a/audio/softsynth/opl/mame.cpp b/audio/softsynth/opl/mame.cpp
index 74699ba4c6..15e869ba33 100644
--- a/audio/softsynth/opl/mame.cpp
+++ b/audio/softsynth/opl/mame.cpp
@@ -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++) {
-- 
cgit v1.2.3