Skip to content

fix: stack buffer underflow in tim_sort.cpp #2722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

vil02
Copy link
Member

@vil02 vil02 commented Sep 2, 2024

Description of Change

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

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:
Fixes memory issue in tim_sport.

@vil02 vil02 marked this pull request as ready for review September 2, 2024 15:41
@realstealthninja
Copy link
Collaborator

realstealthninja commented Sep 2, 2024

note: fixes memory issue in timsort

There are no dynamic allocations in this file?

@vil02
Copy link
Member Author

vil02 commented Sep 3, 2024

note: fixes memory issue in timsort

There are no dynamic allocations in this file?

There are:

int *left = new int[len1], *right = new int[len2];

But they are cleaned afterwards:

delete[] left;

@realstealthninja
Copy link
Collaborator

I see thank you for the clarification 🙂

@realstealthninja realstealthninja merged commit c652c4f into TheAlgorithms:master Sep 3, 2024
10 checks passed
@vil02 vil02 deleted the stack-buffer-underflow_tim_sort_patch branch September 3, 2024 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants