From b539af865ea3217a50c8e4cbf0f668807c134356 Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Wed, 26 Jan 2022 16:00:04 -0600 Subject: cpukit: Prevent error with disabled stack checker When the stack checker is not enabled, the stack checker reporting function can still be called. This prevents that call from performing a null memory access in trying to find the high water mark if the stack checker was never initialized. This also introduces a test to ensure this call does not cause a crash. Closes #4588 --- cpukit/libmisc/stackchk/check.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cpukit/libmisc/stackchk/check.c') diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c index a2b63345d9..fa0c3ea1ed 100644 --- a/cpukit/libmisc/stackchk/check.c +++ b/cpukit/libmisc/stackchk/check.c @@ -410,6 +410,11 @@ static bool Stack_check_Dump_stack_usage( void *low; void *high_water_mark; + /* This is likely to occur if the stack checker is not actually enabled */ + if ( stack->area == NULL ) { + return false; + } + low = Stack_check_Usable_stack_start(stack); size = Stack_check_Usable_stack_size(stack); -- cgit v1.2.3