From 2c5d09bf203a88bcbda5da19843437fcfe7b4525 Mon Sep 17 00:00:00 2001 From: Xenoamor Date: Wed, 18 Jul 2018 16:05:10 +0100 Subject: [PATCH] Flush unity output before a potential longjmp Flush the unity stdout buffer before calling TEST_ABORT(). This is because if TEST_PROTECT() has not previously been called this will cause a segmentation fault and the stdout buffer will fail to print Although the segmentation fault will still occur, the error that caused it will at least be displayed --- src/unity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unity.c b/src/unity.c index 136e9d7..44a8003 100644 --- a/src/unity.c +++ b/src/unity.c @@ -14,8 +14,8 @@ void UNITY_OUTPUT_CHAR(int); #endif /* Helpful macros for us to use here in Assert functions */ -#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; TEST_ABORT(); } -#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; TEST_ABORT(); } +#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } +#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } #define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) return struct UNITY_STORAGE_T Unity; -- GitLab