mirror of https://github.com/OpenTTD/OpenTTD
(svn r25558) -Fix [FS#5568]: [Squirrel] Infinite recursion loop in freeing data via a looping set of references
parent
1e715bfbea
commit
3f7fdd738b
|
@ -37,9 +37,13 @@ public:
|
||||||
~sqvector()
|
~sqvector()
|
||||||
{
|
{
|
||||||
if(_allocated) {
|
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++)
|
for(SQUnsignedInteger i = 0; i < _size; i++)
|
||||||
_vals[i].~T();
|
_vals[i].~T();
|
||||||
SQ_FREE(_vals, (_allocated * sizeof(T)));
|
SQ_FREE(_vals, allocated_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void reserve(SQUnsignedInteger newsize) { _realloc(newsize); }
|
void reserve(SQUnsignedInteger newsize) { _realloc(newsize); }
|
||||||
|
|
Loading…
Reference in New Issue