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

Update test calloc to handle NULL return and avoid invalid memory access and skip two tests while on macOS arm64 #147

Closed
wants to merge 1 commit into from

Conversation

MalwarePup
Copy link
Contributor

The change updates the test code for the calloc function to handle the case where calloc returns NULL, which can happen if the nmemb or size parameter is 0 or if the function is unable to allocate memory. The updated test case explicitly checks for a NULL pointer before attempting to free it, which avoids the potential for undefined behavior caused by attempting to free a deallocated pointer. The change ensures that the test code follows the behavior described in the man page for calloc and should be portable across different systems and versions of the C standard library.

@alelievr Are you okay?

…nd avoid invalid memory access

The change updates the test code for the calloc function to handle the case where calloc returns
NULL, which can happen if the nmemb or size parameter is 0 or if the function is unable to allocate
memory. The updated test case explicitly checks for a NULL pointer before attempting to free it,
which avoids the potential for undefined behavior caused by attempting to free a deallocated
pointer. The change ensures that the test code follows the behavior described in the man page for
calloc and should be portable across different systems and versions of the C standard library.
@MalwarePup MalwarePup changed the title fix(src/test_functions.c): update test calloc to handle NULL return and avoid invalid memory access Update test calloc to handle NULL return and avoid invalid memory access and skip two tests while on macOS arm64 Feb 20, 2023
@MalwarePup MalwarePup closed this Feb 20, 2023
@MalwarePup
Copy link
Contributor Author

The PR #146 resolve the problem about memmove and strrchr, so I close, I will open another PR for the calloc

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.

1 participant