diff options
| author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2026-04-28 11:45:10 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-28 11:45:10 -0400 |
| commit | 10f13b36560c5112554c54d8958081b7aa518050 (patch) | |
| tree | bd27866c4352de38ebc5b13f8208768d576ae904 /tests/test_str.c | |
| parent | 017bc273aedf3f20512beeb78a2f513913e56305 (diff) | |
| parent | d761cc976a8d645e61d23f6e43dcfec1a7fdb061 (diff) | |
| download | stasis-10f13b36560c5112554c54d8958081b7aa518050.tar.gz | |
Merge pull request #137 from jhunkeler/bughunt-1001
Bug Hunt 0x1001
Diffstat (limited to 'tests/test_str.c')
| -rw-r--r-- | tests/test_str.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/test_str.c b/tests/test_str.c index aac5d71..09d8809 100644 --- a/tests/test_str.c +++ b/tests/test_str.c @@ -38,6 +38,7 @@ void test_tolower_s() { for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { char input[100] = {0}; strncpy(input, tc[i].data, sizeof(input) - 1); + input[sizeof(input) - 1] = '\0'; tolower_s(input); STASIS_ASSERT(strcmp(input, tc[i].expected) == 0, "unexpected result"); } @@ -318,6 +319,7 @@ void test_lstrip() { for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { char *buf = calloc(255, sizeof(*buf)); strncpy(buf, tc[i].data, 254); + buf[254] = '\0'; char *result = lstrip(buf); STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "incorrect strip-from-left"); guard_free(buf); @@ -342,6 +344,7 @@ void test_strip() { for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { char *buf = calloc(255, sizeof(*buf)); strncpy(buf, tc[i].data, 254); + buf[254] = '\0'; char *result = strip(buf); STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "incorrect strip-from-right"); guard_free(buf); |
