mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-07-28 23:07:46 +00:00
Improve safety of a test helper
In case parsing fails and we free the pointer, we should also set it to NULL. Otherwise, we get a double-free when the caller tries to free it as well. This can only happen with bad test data, but it tripped me up during development. (I got bad test data because bignum_common.invmod() sometimes returned a negative value, which was a surprise to me, see previous commit.) Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
This commit is contained in:
@@ -71,6 +71,7 @@ int mbedtls_test_read_mpi_core(mbedtls_mpi_uint **pX, size_t *plimbs,
|
||||
|
||||
exit:
|
||||
mbedtls_free(*pX);
|
||||
*pX = NULL;
|
||||
return MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user