Print this page
5158 sed dumps core in new multibyte code
Reviewed by: Toomas Soome <tsoome@me.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/locale/mbsrtowcs.c
          +++ new/usr/src/lib/libc/port/locale/mbsrtowcs.c
↓ open down ↓ 31 lines elided ↑ open up ↑
  32   32  #include <stdlib.h>
  33   33  #include <wchar.h>
  34   34  #include "mblocal.h"
  35   35  #include "localeimpl.h"
  36   36  #include "lctype.h"
  37   37  
  38   38  size_t
  39   39  mbsrtowcs_l(wchar_t *_RESTRICT_KYWD dst, const char **_RESTRICT_KYWD src,
  40   40      size_t len, mbstate_t *_RESTRICT_KYWD ps, locale_t loc)
  41   41  {
       42 +        static mbstate_t mbs;
       43 +
       44 +        if (ps == NULL)
       45 +                ps = &mbs;
       46 +
  42   47          return (loc->ctype->lc_mbsnrtowcs(dst, src, ULONG_MAX, len, ps));
  43   48  }
  44   49  
  45   50  size_t
  46   51  mbsrtowcs(wchar_t *_RESTRICT_KYWD dst, const char **_RESTRICT_KYWD src,
  47   52      size_t len, mbstate_t *_RESTRICT_KYWD ps)
  48   53  {
  49   54          return (mbsrtowcs_l(dst, src, len, ps, uselocale(NULL)));
  50   55  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX