From 5112d7dfbd24faf8483dcb7a0052add48c21cad3 Mon Sep 17 00:00:00 2001 From: jsalling Date: Fri, 6 Jan 2017 20:45:33 -0600 Subject: [PATCH] Use default int size for any bad STYLE_T enum value Defensive coding --- src/unity.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/unity.c b/src/unity.c index c1be293..a0e9986 100644 --- a/src/unity.c +++ b/src/unity.c @@ -580,9 +580,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, const UNITY_DISPLAY_STYLE_T style) { UNITY_UINT32 elements = num_elements; - const unsigned int length = style & 0xF; - UNITY_INT expect_val = 0; - UNITY_INT actual_val = 0; + unsigned int length = style & 0xF; UNITY_SKIP_EXECUTION; @@ -596,6 +594,8 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, while (elements--) { + UNITY_INT expect_val; + UNITY_INT actual_val; switch (length) { case 1: @@ -609,6 +609,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, default: /* length 4 bytes */ expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + length = 4; break; #ifdef UNITY_SUPPORT_64 case 8: @@ -637,8 +638,8 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } - expected = length + (const char*)expected; - actual = length + (const char*)actual; + expected = (UNITY_INTERNAL_PTR)(length + (const char*)expected); + actual = (UNITY_INTERNAL_PTR)(length + (const char*)actual); } }