From 47b8de834dfb40f12c972ca799c26d17660f1619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 14 Oct 2022 09:35:55 +0200 Subject: [PATCH] Fix usage of ASSERT_ALLOC() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The second argument is the number of elements of the type the first argument is pointing to, so we shouldn't be using sizeof there. This was resulting in overly large allocations. Signed-off-by: Manuel Pégourié-Gonnard --- tests/suites/test_suite_asn1parse.function | 2 +- tests/suites/test_suite_ssl.function | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_asn1parse.function b/tests/suites/test_suite_asn1parse.function index 87901f8fa..002d8c426 100644 --- a/tests/suites/test_suite_asn1parse.function +++ b/tests/suites/test_suite_asn1parse.function @@ -779,7 +779,7 @@ void free_named_data_list( int length ) for( i = 0; i < length; i++ ) { mbedtls_asn1_named_data *new = NULL; - ASSERT_ALLOC( new, sizeof( mbedtls_asn1_named_data ) ); + ASSERT_ALLOC( new, 1 ); new->next = head; head = new; } diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 7b5743ece..d832853ee 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -137,7 +137,7 @@ void init_handshake_options( handshake_test_options *opts ) opts->resize_buffers = 1; #if defined(MBEDTLS_SSL_CACHE_C) opts->cache = NULL; - ASSERT_ALLOC( opts->cache, sizeof( mbedtls_ssl_cache_context ) ); + ASSERT_ALLOC( opts->cache, 1 ); mbedtls_ssl_cache_init( opts->cache ); exit: return;