You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second test case used SIZE_MAX * 2 to test the another_calloc function.
However, if I comment out the if statement that checks the overflow, the function would still run fine with the given argument. It is because the malloc function will return NULL if the provided argument is way too big. The argument SIZE_MAX * 2 on a 64-bit machine returns 18446744073709551614, which is SIZE_MAX - 1, hence malloc (SIZE_MAX *2) will return NULL even if the overflow did occur in this case.
I think it is better to test the function by using two smaller arguments, such as (2^40)+1 and 2^24, but still causing overflow.
The text was updated successfully, but these errors were encountered:
The second test case used SIZE_MAX * 2 to test the another_calloc function.
However, if I comment out the if statement that checks the overflow, the function would still run fine with the given argument. It is because the malloc function will return NULL if the provided argument is way too big. The argument SIZE_MAX * 2 on a 64-bit machine returns 18446744073709551614, which is SIZE_MAX - 1, hence malloc (SIZE_MAX *2) will return NULL even if the overflow did occur in this case.
I think it is better to test the function by using two smaller arguments, such as (2^40)+1 and 2^24, but still causing overflow.
The text was updated successfully, but these errors were encountered: