Skip to content

Commit a84142f

Browse files
committed
Prevent recursive call to error()
Only allow error to be called once. This prevents a loop where error() calls exit() which in turn triggers another call to exit().
1 parent 770ad61 commit a84142f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

platform/mbed_error.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@
2323
#include <stdio.h>
2424
#endif
2525

26+
static uint8_t error_in_progress = 0;
27+
2628
WEAK void error(const char* format, ...) {
29+
30+
// Prevent recursion if error is called again
31+
if (error_in_progress) {
32+
return;
33+
}
34+
error_in_progress = 1;
35+
2736
#ifndef NDEBUG
2837
va_list arg;
2938
va_start(arg, format);

0 commit comments

Comments
 (0)