summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-07-04 20:06:27 +0000
committerrubidium <rubidium@openttd.org>2013-07-04 20:06:27 +0000
commit3f7fdd738b1941c9b074438e175eaacc889ab9df (patch)
tree9fe19b0607abb17c7049498d8bfa9e81a3efede1 /src
parent1e715bfbea56038588e5fcdad8bab92422e4c4dc (diff)
downloadopenttd-3f7fdd738b1941c9b074438e175eaacc889ab9df.tar.xz
(svn r25558) -Fix [FS#5568]: [Squirrel] Infinite recursion loop in freeing data via a looping set of references
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/squirrel/squirrel/squtils.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/3rdparty/squirrel/squirrel/squtils.h b/src/3rdparty/squirrel/squirrel/squtils.h
index 5f7e2e239..111a1c383 100644
--- a/src/3rdparty/squirrel/squirrel/squtils.h
+++ b/src/3rdparty/squirrel/squirrel/squtils.h
@@ -37,9 +37,13 @@ public:
~sqvector()
{
if(_allocated) {
+ /* Break freeing loops, if this vector (indirectly) links to itself. */
+ size_t allocated_size = _allocated * sizeof(T);
+ _allocated = 0;
+
for(SQUnsignedInteger i = 0; i < _size; i++)
_vals[i].~T();
- SQ_FREE(_vals, (_allocated * sizeof(T)));
+ SQ_FREE(_vals, allocated_size);
}
}
void reserve(SQUnsignedInteger newsize) { _realloc(newsize); }