Skip to content

Commit 54ae6d1

Browse files
committed
Fix teststr segfault when built with -ftrivial-auto-var-init
* test/teststr.c -- one test case was broken and worked by accident: the apr_strtok() function was intentionally called with `str == NULL` on first invocation. This leads to an access to `*internal_state`, which is technically undefined (uninitialized pointer on the stack). Without `-ftrivial-auto-var-init`, the `*internal_state` is benign by accident: the previous test case left the pointer-on-stack with some reasonable address. However, with `-ftrivial-auto-var-init=zero`, the `*internal_state` access fails because `internal_state = NULL` (auto-initialized to zero). So the whole test segfaults. This commit comments out this broken test case.
1 parent e461da5 commit 54ae6d1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/teststr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ static void test_strtok(abts_case *tc, void *data)
4848
" asdf jkl; 77889909 \r\n\1\2\3Z",
4949
" \r\n\3\2\1"
5050
},
51+
#if 0
52+
/* don't do this... apr_strtok() is not supposed to be called with
53+
* str == NULL in the first invocation, otherwise it segfaults.
54+
*/
5155
{
52-
NULL, /* but who cares if apr_strtok() segfaults? */
56+
NULL,
5357
" \t"
5458
},
59+
#endif
5560
#if 0 /* don't do this... you deserve to segfault */
5661
{
5762
"a b c ",

0 commit comments

Comments
 (0)