Skip to content

Conversation

@The-AarushiSingh
Copy link

Description of Change

Fixed an out-of-bounds access issue in sorting/counting_sort_string.cpp by pre-allocating the output string with the correct size.

The previous implementation initialized an empty string and wrote to specific indices, causing undefined behavior and potential crashes.
Now, the output string is initialized as string output(n, ' '); to ensure safe memory access and correct sorting behavior.


Checklist

  • Added description of change
  • File name follows File name guidelines
  • Tested with sample inputs to verify correct output
  • Added inline documentation for clarity
  • PR title follows semantic commit guidelines
  • I acknowledge that all my contributions will be made under the project's license

Notes

This PR addresses issue #3055 and ensures countSort runs safely without segmentation faults or memory corruption.

@github-actions
Copy link
Contributor

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Nov 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!

@github-actions github-actions bot closed this Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Author has not responded to the comments for over 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant