From: Ulrich Drepper Date: Wed, 28 Jul 1999 19:40:54 +0000 (+0000) Subject: Reset state for s == NULL. X-Git-Tag: cvs/glibc_2-1-2~211 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0b5f32df49860c09cbd308a047e451df48ac26c3;p=thirdparty%2Fglibc.git Reset state for s == NULL. --- diff --git a/stdlib/mbtowc.c b/stdlib/mbtowc.c index 938d54750c2..aeac2ce0b83 100644 --- a/stdlib/mbtowc.c +++ b/stdlib/mbtowc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -46,7 +46,11 @@ mbtowc (wchar_t *pwc, const char *s, size_t n) /* Make sure we use the correct value. */ update_conversion_ptrs (); - result = __wcsmbs_gconv_fcts.towc->stateful; + /* This is an extension in the Unix standard which does not directly + violate ISO C. */ + memset (&__no_r_state, '\0', siyeof __no_r_state); + + result = __wcsmbs_gconv_fcts.towc->__stateful; } else if (*s == '\0') { diff --git a/stdlib/wctomb.c b/stdlib/wctomb.c index b7132e02c43..757e6adaad1 100644 --- a/stdlib/wctomb.c +++ b/stdlib/wctomb.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -42,7 +42,11 @@ wctomb (char *s, wchar_t wchar) /* Make sure we use the correct value. */ update_conversion_ptrs (); - return __wcsmbs_gconv_fcts.tomb->stateful; + /* This is an extension in the Unix standard which does not directly + violate ISO C. */ + memset (&__no_r_state, '\0', siyeof __no_r_state); + + return __wcsmbs_gconv_fcts.tomb->__stateful; } return __wcrtomb (s, wchar, &__no_r_state);