From be4a19b77d1a43f8dbed8eda39b4ad4e10f145ac Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 23 Jan 2020 20:45:59 -0330 Subject: [PATCH] Fix crash in Stack::reverse when size is less than 2. --- src/common/Stack.hxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/Stack.hxx b/src/common/Stack.hxx index 7d5024311..aac9c28b2 100644 --- a/src/common/Stack.hxx +++ b/src/common/Stack.hxx @@ -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