mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-30 15:32:58 +00:00
22e84de971
Trusting the caller to perform the appropriate check is both risky, and a bit user-unfriendly. Returning NULL on error seems both safer (dereferencing a NULL pointer is more likely to result in a clean crash, while mis-casting a pointer might have deeper, less predictable consequences) and friendlier (the caller can just check the return value for NULL, which is a common idiom). Only add that as an additional way of using the function, for the sake of backwards compatibility. Calls where we know the type of the context for sure (for example because we just set it up) were legal and safe, so they should remain legal without checking the result for NULL, which would be redundant. Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>