alelievr / libft-unit-test

456 stars 88 forks source link

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

Closed MalwarePup closed 1 year ago

MalwarePup commented 1 year ago

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?

MalwarePup commented 1 year ago

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