Fix overflow bug when comparing strings
This commit is contained in:
parent
e50fbff2d1
commit
1b80c00658
@ -41,8 +41,8 @@ extern tt_test tt_tests[];
|
|||||||
|
|
||||||
#define ASSERT_STRN(lhs, rhs, n) do { \
|
#define ASSERT_STRN(lhs, rhs, n) do { \
|
||||||
size_t tt_n = (size_t)(n); \
|
size_t tt_n = (size_t)(n); \
|
||||||
char *tt_lhs = malloc(tt_n); \
|
char *tt_lhs = malloc(tt_n+1); \
|
||||||
char *tt_rhs = malloc(tt_n); \
|
char *tt_rhs = malloc(tt_n+1); \
|
||||||
memcpy(tt_lhs, (lhs), tt_n); \
|
memcpy(tt_lhs, (lhs), tt_n); \
|
||||||
memcpy(tt_rhs, (rhs), tt_n); \
|
memcpy(tt_rhs, (rhs), tt_n); \
|
||||||
tt_rhs[tt_n] = tt_lhs[tt_n] = '\0'; \
|
tt_rhs[tt_n] = tt_lhs[tt_n] = '\0'; \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user