# HG changeset patch # User Bruno Haible # Date 1297616695 -3600 # Node ID 5cdebc45677d57c14b3dec8a6e70a4fa8451f3c1 # Parent 8e436083745123c19e3f4e8bb3360003c3a4253f mbsinit: Don't crash for a NULL argument. * lib/mbsinit.c (mbsinit): When the argument is NULL, return 1. * tests/test-mbsinit.c (mbsinit): Check this behaviour. diff -r 8e4360837451 -r 5cdebc45677d ChangeLog --- a/ChangeLog Sun Feb 13 11:59:12 2011 +0100 +++ b/ChangeLog Sun Feb 13 18:04:55 2011 +0100 @@ -1,3 +1,9 @@ +2011-02-13 Bruno Haible + + mbsinit: Don't crash for a NULL argument. + * lib/mbsinit.c (mbsinit): When the argument is NULL, return 1. + * tests/test-mbsinit.c (mbsinit): Check this behaviour. + 2011-02-13 Bruno Haible Don't interfere with a program's definition of __attribute__. diff -r 8e4360837451 -r 5cdebc45677d lib/mbsinit.c --- a/lib/mbsinit.c Sun Feb 13 11:59:12 2011 +0100 +++ b/lib/mbsinit.c Sun Feb 13 18:04:55 2011 +0100 @@ -43,5 +43,5 @@ { const char *pstate = (const char *)ps; - return pstate[0] == 0; + return pstate == NULL || pstate[0] == 0; } diff -r 8e4360837451 -r 5cdebc45677d tests/test-mbsinit.c --- a/tests/test-mbsinit.c Sun Feb 13 11:59:12 2011 +0100 +++ b/tests/test-mbsinit.c Sun Feb 13 18:04:55 2011 +0100 @@ -32,6 +32,8 @@ { static mbstate_t state; + ASSERT (mbsinit (NULL)); + ASSERT (mbsinit (&state)); if (argc > 1)