aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/players
diff options
context:
space:
mode:
authorAdrian Frühwirth2018-05-17 12:40:02 +0200
committerAdrian Frühwirth2018-06-01 17:08:39 +0000
commit56d2bf77bae50bb1cb0eab01841cd1a9e7057f30 (patch)
tree2f7c2727bc1a18e529fb89a087fbc3903a3e466c /engines/scumm/players
parent7da892a4a2ac871929b4b5555c6fae76a0fd99ac (diff)
downloadscummvm-rg350-56d2bf77bae50bb1cb0eab01841cd1a9e7057f30.tar.gz
scummvm-rg350-56d2bf77bae50bb1cb0eab01841cd1a9e7057f30.tar.bz2
scummvm-rg350-56d2bf77bae50bb1cb0eab01841cd1a9e7057f30.zip
SCUMM: Ensure pointer returned by getResourceAddress() is usable
In some cases the pointer returned is used directly without further error checking. As most instances already assert() in this case this commit simply adds asserts where missing and deemed appropriate.
Diffstat (limited to 'engines/scumm/players')
-rw-r--r--engines/scumm/players/player_ad.cpp1
-rw-r--r--engines/scumm/players/player_towns.cpp3
2 files changed, 4 insertions, 0 deletions
diff --git a/engines/scumm/players/player_ad.cpp b/engines/scumm/players/player_ad.cpp
index 7f0f449a92..40f4ec93c9 100644
--- a/engines/scumm/players/player_ad.cpp
+++ b/engines/scumm/players/player_ad.cpp
@@ -97,6 +97,7 @@ void Player_AD::startSound(int sound) {
// Query the sound resource
const byte *res = _vm->getResourceAddress(rtSound, sound);
+ assert(res);
if (res[2] == 0x80) {
// Stop the current sounds
diff --git a/engines/scumm/players/player_towns.cpp b/engines/scumm/players/player_towns.cpp
index 16080205c0..a1add906bb 100644
--- a/engines/scumm/players/player_towns.cpp
+++ b/engines/scumm/players/player_towns.cpp
@@ -236,6 +236,8 @@ void Player_Towns_v1::setMusicVolume(int vol) {
void Player_Towns_v1::startSound(int sound) {
uint8 *ptr = _vm->getResourceAddress(rtSound, sound);
+ assert(ptr);
+
if (_vm->_game.version != 3)
ptr += 2;
@@ -620,6 +622,7 @@ int Player_Towns_v2::getSoundStatus(int sound) const {
void Player_Towns_v2::startSound(int sound) {
uint8 *ptr = _vm->getResourceAddress(rtSound, sound);
+ assert(ptr);
if (READ_BE_UINT32(ptr) == MKTAG('T','O','W','S')) {
_soundOverride[sound].type = 7;