From e4dc5336db4f2e864aa5b7d1496c00169ef69b50 Mon Sep 17 00:00:00 2001 From: Julien Templier Date: Sun, 24 Oct 2010 22:15:25 +0000 Subject: LASTEXPRESS: Fix crash in subtitle handling svn-id: r53777 --- engines/lastexpress/data/subtitle.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'engines/lastexpress') diff --git a/engines/lastexpress/data/subtitle.cpp b/engines/lastexpress/data/subtitle.cpp index 08652a293d..67d6445ab9 100644 --- a/engines/lastexpress/data/subtitle.cpp +++ b/engines/lastexpress/data/subtitle.cpp @@ -96,14 +96,18 @@ bool Subtitle::load(Common::SeekableReadStream *in) { // Create the buffers if (_topLength) { - _topText = newArray(_topLength); + _topText = newArray(_topLength + 1); if (!_topText) return false; + + _topText[_topLength] = 0; } if (_bottomLength) { - _bottomText = newArray(_bottomLength); + _bottomText = newArray(_bottomLength + 1); if (!_bottomText) return false; + + _bottomText[_bottomLength] = 0; } // Read the texts @@ -142,6 +146,7 @@ SubtitleManager::SubtitleManager(Font *font) : _font(font), _maxTime(0), _curren SubtitleManager::~SubtitleManager() { reset(); + // Zero passed pointers _font = NULL; } @@ -152,9 +157,6 @@ void SubtitleManager::reset() { _subtitles.clear(); _currentIndex = -1; _lastIndex = -1; - - // Zero passed pointers - _font = NULL; } bool SubtitleManager::load(Common::SeekableReadStream *stream) { -- cgit v1.2.3