From 8262072d915cd289cb2a2d48281f96166c37c32a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 10 Oct 2024 07:59:32 -0700 Subject: [PATCH] Fixed possible memset(NULL) call in testautomation's SDL_aligned_alloc() check Fixes https://github.com/libsdl-org/SDL/issues/11144 --- test/testautomation_stdlib.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c index b3ed82ab71..9ed7f31289 100644 --- a/test/testautomation_stdlib.c +++ b/test/testautomation_stdlib.c @@ -913,9 +913,11 @@ static int SDLCALL stdlib_aligned_alloc(void *arg) } SDLTest_AssertCheck(ptr != NULL, "Check output, expected non-NULL, got: %p", ptr); SDLTest_AssertCheck((((size_t)ptr) % alignment) == 0, "Check output, expected aligned pointer, actual offset: %"SIZE_FORMAT, (((size_t)ptr) % alignment)); - SDLTest_AssertPass("Filling memory to alignment value"); - SDL_memset(ptr, 0xAA, alignment); - SDL_aligned_free(ptr); + if (ptr != NULL) { + SDLTest_AssertPass("Filling memory to alignment value"); + SDL_memset(ptr, 0xAA, alignment); + SDL_aligned_free(ptr); + } } return TEST_COMPLETED;