diff options
author | Julien | 2011-06-05 05:22:40 +0800 |
---|---|---|
committer | Julien | 2011-06-23 15:11:37 +0800 |
commit | 367605d774df038166b14044a5f5ce935f244519 (patch) | |
tree | 051917f11e3d00cffc4d0deb2e9415b7e69903be /engines/toon | |
parent | 5aa1877beffa71a2cc712a85b74a788e22a924e2 (diff) | |
download | scummvm-rg350-367605d774df038166b14044a5f5ce935f244519.tar.gz scummvm-rg350-367605d774df038166b14044a5f5ce935f244519.tar.bz2 scummvm-rg350-367605d774df038166b14044a5f5ce935f244519.zip |
TSAGE: Allocate resource decoding buffer on the heap
Diffstat (limited to 'engines/toon')
-rw-r--r-- | engines/toon/path.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp index dde7be07d0..43a134e39b 100644 --- a/engines/toon/path.cpp +++ b/engines/toon/path.cpp @@ -342,8 +342,15 @@ next: curX = destx; curY = desty; - int32 retPathX[4096]; - int32 retPathY[4096]; + int32 *retPathX = (int32 *)malloc(4096 * sizeof(int32)); + int32 *retPathY = (int32 *)malloc(4096 * sizeof(int32)); + if (!retPathX || !retPathY) { + free(retPathX); + free(retPathY); + + error("[PathFinding::findPath] Cannot allocate pathfinding buffers"); + } + int32 numpath = 0; retPathX[numpath] = curX; @@ -377,8 +384,12 @@ next: } } - if (bestX < 0 || bestY < 0) + if (bestX < 0 || bestY < 0) { + free(retPathX); + free(retPathY); + return 0; + } retPathX[numpath] = bestX; retPathY[numpath] = bestY; @@ -389,6 +400,10 @@ next: memcpy(_tempPathX, retPathX, sizeof(int32) * numpath); memcpy(_tempPathY, retPathY, sizeof(int32) * numpath); + + free(retPathX); + free(retPathY); + return true; } @@ -396,6 +411,9 @@ next: curY = bestY; } + free(retPathX); + free(retPathY); + return false; } |