mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-26 03:17:59 +08:00
Use default int size for any bad STYLE_T enum value
Defensive coding
This commit is contained in:
11
src/unity.c
11
src/unity.c
@ -580,9 +580,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
|||||||
const UNITY_DISPLAY_STYLE_T style)
|
const UNITY_DISPLAY_STYLE_T style)
|
||||||
{
|
{
|
||||||
UNITY_UINT32 elements = num_elements;
|
UNITY_UINT32 elements = num_elements;
|
||||||
const unsigned int length = style & 0xF;
|
unsigned int length = style & 0xF;
|
||||||
UNITY_INT expect_val = 0;
|
|
||||||
UNITY_INT actual_val = 0;
|
|
||||||
|
|
||||||
UNITY_SKIP_EXECUTION;
|
UNITY_SKIP_EXECUTION;
|
||||||
|
|
||||||
@ -596,6 +594,8 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
|||||||
|
|
||||||
while (elements--)
|
while (elements--)
|
||||||
{
|
{
|
||||||
|
UNITY_INT expect_val;
|
||||||
|
UNITY_INT actual_val;
|
||||||
switch (length)
|
switch (length)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -609,6 +609,7 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
|||||||
default: /* length 4 bytes */
|
default: /* length 4 bytes */
|
||||||
expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected;
|
expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected;
|
||||||
actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual;
|
actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual;
|
||||||
|
length = 4;
|
||||||
break;
|
break;
|
||||||
#ifdef UNITY_SUPPORT_64
|
#ifdef UNITY_SUPPORT_64
|
||||||
case 8:
|
case 8:
|
||||||
@ -637,8 +638,8 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
|
|||||||
UnityAddMsgIfSpecified(msg);
|
UnityAddMsgIfSpecified(msg);
|
||||||
UNITY_FAIL_AND_BAIL;
|
UNITY_FAIL_AND_BAIL;
|
||||||
}
|
}
|
||||||
expected = length + (const char*)expected;
|
expected = (UNITY_INTERNAL_PTR)(length + (const char*)expected);
|
||||||
actual = length + (const char*)actual;
|
actual = (UNITY_INTERNAL_PTR)(length + (const char*)actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user