From 967ef350d29106580baa48ab63cfaeff7c628ae8 Mon Sep 17 00:00:00 2001 From: Retro-Junk Date: Thu, 25 Aug 2016 23:13:37 +0300 Subject: FULLPIPE: Fix array allocation in StepArray::insertPoints --- engines/fullpipe/statics.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index a5bbf21151..de1fc77b13 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -108,20 +108,22 @@ bool StepArray::gotoNextPoint() { void StepArray::insertPoints(Common::Point **points, int pointsCount) { if (_currPointIndex + pointsCount >= _pointsCount) { - _points = (Common::Point **)realloc(_points, sizeof(Common::Point *) * (_currPointIndex + pointsCount)); + _points = (Common::Point **)realloc(_points, sizeof(Common::Point *) * (_pointsCount + pointsCount)); if (!_points) { error("Out of memory at StepArray::insertPoints()"); } + + for(int i = 0; i < pointsCount; i++) + _points[_pointsCount + i] = new Common::Point; + + _pointsCount += pointsCount; } _maxPointIndex = _currPointIndex + pointsCount; - for (int i = 0; i < pointsCount; i++) { - _points[_currPointIndex + i] = new Common::Point; - + for (int i = 0; i < pointsCount; i++) *_points[_currPointIndex + i] = *points[i]; - } } StaticANIObject::StaticANIObject() { -- cgit v1.2.3