TheAlgorithms / C-Plus-Plus

Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
https://thealgorithms.github.io/C-Plus-Plus
MIT License
30.68k stars 7.27k forks source link

fix: stack buffer underflow in `tim_sort.cpp` #2722

Closed vil02 closed 2 months ago

vil02 commented 2 months ago

Description of Change

tim_sport has a stack buffer underflow. This PR fixes it and runs clang-format on this file.

Checklist

Notes: Fixes memory issue in tim_sport.

realstealthninja commented 2 months ago

note: fixes memory issue in timsort

There are no dynamic allocations in this file?

vil02 commented 2 months ago

note: fixes memory issue in timsort

There are no dynamic allocations in this file?

There are: https://github.com/TheAlgorithms/C-Plus-Plus/blob/b6108e494dbd9ef05926fc5e8bc7f60147445ecb/sorting/tim_sort.cpp#L27

But they are cleaned afterwards: https://github.com/TheAlgorithms/C-Plus-Plus/blob/b6108e494dbd9ef05926fc5e8bc7f60147445ecb/sorting/tim_sort.cpp#L60

realstealthninja commented 2 months ago

I see thank you for the clarification 🙂