Skip to content
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

fix: Prevent segmentation fault at Simple generic Stack #1463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Artursrossi
Copy link

Description of Change

  • Prevent segmentation fault error at stack.c grow function
    • After malloc, there is an iteration without any check if malloc returned null

References

Checklist

  • Added description of change
  • 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: Used realloc instead of malloc

Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle this is a change in a very good direction: standard functions are always better than manual work.

Copy link
Author

@Artursrossi Artursrossi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used assert() function just to maintain the file code standard. In other functions like initStack(), push() and pop(), the original author chose to use assert().

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