Fix crash in Stack::reverse when size is less than 2.

This commit is contained in:
Stephen Anthony 2020-01-23 20:45:59 -03:30
parent 1fc3c62a91
commit c1781e5492
1 changed files with 3 additions and 2 deletions

View File

@ -51,8 +51,9 @@ class FixedStack
// Reverse the contents of the stack
// This operation isn't needed very often, but it's handy to have
void reverse() {
for(uInt32 i = 0, j = _size - 1; i < j; ++i, --j)
std::swap(_stack[i], _stack[j]);
if(_size > 1)
for(uInt32 i = 0, j = _size - 1; i < j; ++i, --j)
std::swap(_stack[i], _stack[j]);
}
// Apply the given function to every item in the stack