From 45e8078dab1be71a9ef5d125fa80ff660aa0cd5c Mon Sep 17 00:00:00 2001 From: uruk Date: Wed, 13 Aug 2014 17:54:35 +0200 Subject: CGE2: Don't allow Sprite::step() to dereference nullptr-s. --- engines/cge2/vga13h.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp index 9141f426f3..db96682237 100644 --- a/engines/cge2/vga13h.cpp +++ b/engines/cge2/vga13h.cpp @@ -516,7 +516,7 @@ void Sprite::step(int nr) { if (nr >= 0) _seqPtr = nr; - if (_ext) { + if (_ext && _ext->_seq) { V3D p = _pos3D; Seq *seq = nullptr; @@ -556,13 +556,15 @@ void Sprite::step(int nr) { gotoxyz(p); } else { seq = _ext->_seq + _seqPtr; - if (seq->_dz == 127 && seq->_dx != 0) { - _vm->_commandHandlerTurbo->addCommand(kCmdSound, -1, 256 * seq->_dy + seq->_dx, this); - } else { - p._x += seq->_dx; - p._y += seq->_dy; - p._z += seq->_dz; - gotoxyz(p); + if (seq) { + if (seq->_dz == 127 && seq->_dx != 0) { + _vm->_commandHandlerTurbo->addCommand(kCmdSound, -1, 256 * seq->_dy + seq->_dx, this); + } else { + p._x += seq->_dx; + p._y += seq->_dy; + p._z += seq->_dz; + gotoxyz(p); + } } } if (seq && (seq->_dly >= 0)) -- cgit v1.2.3