mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Always check return status of mutex_(un)lock()
This commit is contained in:
@ -542,17 +542,22 @@ void mbedtls_memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks )
|
||||
static void *buffer_alloc_malloc_mutexed( size_t len )
|
||||
{
|
||||
void *buf;
|
||||
mbedtls_mutex_lock( &heap.mutex );
|
||||
if( mbedtls_mutex_lock( &heap.mutex ) != 0 )
|
||||
return( NULL );
|
||||
buf = buffer_alloc_malloc( len );
|
||||
mbedtls_mutex_unlock( &heap.mutex );
|
||||
if( mbedtls_mutex_unlock( &heap.mutex ) )
|
||||
return( NULL );
|
||||
return( buf );
|
||||
}
|
||||
|
||||
static void buffer_alloc_free_mutexed( void *ptr )
|
||||
{
|
||||
mbedtls_mutex_lock( &heap.mutex );
|
||||
/* We have to good option here, but corrupting the heap seems
|
||||
* worse than loosing memory. */
|
||||
if( mbedtls_mutex_lock( &heap.mutex ) )
|
||||
return;
|
||||
buffer_alloc_free( ptr );
|
||||
mbedtls_mutex_unlock( &heap.mutex );
|
||||
(void) mbedtls_mutex_unlock( &heap.mutex );
|
||||
}
|
||||
#endif /* MBEDTLS_THREADING_C */
|
||||
|
||||
|
Reference in New Issue
Block a user