bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mbsinit fix


From: Bruno Haible
Subject: mbsinit fix
Date: Sun, 13 Feb 2011 18:06:24 +0100
User-agent: KMail/1.9.9

mbsinit (NULL) is required to return 1. But gnulib's replacement does not do
it. This fixes it:


2011-02-13  Bruno Haible  <address@hidden>

        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.

--- lib/mbsinit.c.orig  Sun Feb 13 18:02:57 2011
+++ lib/mbsinit.c       Sun Feb 13 18:01:55 2011
@@ -43,5 +43,5 @@
 {
   const char *pstate = (const char *)ps;
 
-  return pstate[0] == 0;
+  return pstate == NULL || pstate[0] == 0;
 }
--- tests/test-mbsinit.c.orig   Sun Feb 13 18:02:57 2011
+++ tests/test-mbsinit.c        Sun Feb 13 18:02:09 2011
@@ -32,6 +32,8 @@
 {
   static mbstate_t state;
 
+  ASSERT (mbsinit (NULL));
+
   ASSERT (mbsinit (&state));
 
   if (argc > 1)

-- 
In memoriam Alexander Samoylovich 
<http://en.wikipedia.org/wiki/Alexander_Samoylovich>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]