about summary refs log tree commit diff
path: root/wcsmbs
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-04-29 07:00:59 +0000
committerUlrich Drepper <drepper@redhat.com>2000-04-29 07:00:59 +0000
commit515ab778a7197136a2ccf873dd27388081b5b6a4 (patch)
treea66299a4721709fb37c543bcec5ce35072054783 /wcsmbs
parentcffad2ae2a03c545a8858645f74c3300a52de7c1 (diff)
downloadglibc-515ab778a7197136a2ccf873dd27388081b5b6a4.tar.gz
glibc-515ab778a7197136a2ccf873dd27388081b5b6a4.tar.xz
glibc-515ab778a7197136a2ccf873dd27388081b5b6a4.zip
(__mbrtowc): Set end of buffer correctly if s == NULL.
Diffstat (limited to 'wcsmbs')
-rw-r--r--wcsmbs/mbrtowc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/wcsmbs/mbrtowc.c b/wcsmbs/mbrtowc.c
index b0daf14fd5..212b001422 100644
--- a/wcsmbs/mbrtowc.c
+++ b/wcsmbs/mbrtowc.c
@@ -43,9 +43,7 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
   const unsigned char *inbuf;
   char *outbuf = (char *) (pwc ?: buf);
 
-  /* Tell where we want the result.  */
-  data.__outbuf = outbuf;
-  data.__outbufend = outbuf + sizeof (wchar_t);
+  /* Set information for this step.  */
   data.__invocation_counter = 0;
   data.__internal_use = 1;
   data.__is_last = 1;
@@ -55,13 +53,17 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
      initial state.  */
   if (s == NULL)
     {
-      data.__outbuf = (char *) buf;
+      outbuf = (char *) buf;
       s = "";
       n = 1;
       temp_state = *data.__statep;
       data.__statep = &temp_state;
     }
 
+  /* Tell where we want the result.  */
+  data.__outbuf = outbuf;
+  data.__outbufend = outbuf + sizeof (wchar_t);
+
   /* Make sure we use the correct function.  */
   update_conversion_ptrs ();