mbsinit: Don't crash for a NULL argument.
[gnulib.git] / lib / mbsinit.c
index 205a55e..869c0a6 100644 (file)
@@ -1,5 +1,5 @@
 /* Test for initial conversion state.
-   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2008-2011 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2008.
 
    This program is free software: you can redistribute it and/or modify
@@ -43,5 +43,5 @@ mbsinit (const mbstate_t *ps)
 {
   const char *pstate = (const char *)ps;
 
-  return pstate[0] == 0;
+  return pstate == NULL || pstate[0] == 0;
 }