Tue, 16 Jan 2024 23:12:43 +0100
fix assertion failure depending on possibly uninitialized memory
tests/test_string.c | file | annotate | diff | comparison | revisions |
1.1 --- a/tests/test_string.c Tue Jan 16 21:34:21 2024 +0100 1.2 +++ b/tests/test_string.c Tue Jan 16 23:12:43 2024 +0100 1.3 @@ -179,8 +179,11 @@ 1.4 size_t const longstrpatternlen = 64 + cx_strstr_sbo_size; 1.5 size_t const longstrlen = 320 + longstrpatternlen + 14; 1.6 1.7 - char *longstrc = malloc(longstrlen+1); 1.8 - char *longstrpatternc = malloc(longstrpatternlen+1); 1.9 + // it is more expensive to use calloc here, because we will overwrite 1.10 + // the memory anyway in the test preparation - but it is more reliable 1.11 + // in case we are doing something horribly wrong 1.12 + char *longstrc = calloc(longstrlen+1, 1); 1.13 + char *longstrpatternc = calloc(longstrpatternlen+1, 1); 1.14 1.15 memcpy(longstrc, 1.16 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl"