mblen(NULL,x) bug
Jonathan Larmour
jlarmour@redhat.com
Fri Jun 8 12:53:00 GMT 2001
It seems there's a long lasting bug which I noticed when doing
mblen(NULL,x) on a target that traps dereferences of NULLs. When s is
(legally) passed as NULL to _mbtowc_r(), it shouldn't dereference it.
Trivial fix below, okay to check in?
Jifl
2001-06-08 Jonathan Larmour <jlarmour@redhat.com>
* libc/stdlib/mbtowc_r.c (_mbtowc_r): Avoid dereferencing
NULL pointer.
--- mbtowc_r.c 1998/08/21 19:47:39 1.3
+++ mbtowc_r.c 2001/06/08 19:49:40
@@ -66,13 +66,14 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state)
if (r->_current_locale == NULL ||
(strlen (r->_current_locale) <= 1))
{ /* fall-through */ }
else if (!strcmp (r->_current_locale, "C-SJIS"))
{
- int char1 = *t;
+ int char1;
if (s == NULL)
return 0; /* not state-dependent */
+ char1 = *t;
if (_issjis1 (char1))
{
int char2 = t[1];
if (n <= 1)
return -1;
@@ -85,13 +86,14 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state)
return -1;
}
}
else if (!strcmp (r->_current_locale, "C-EUCJP"))
{
- int char1 = *t;
+ int char1;
if (s == NULL)
return 0; /* not state-dependent */
+ char1 = *t;
if (_iseucjp (char1))
{
int char2 = t[1];
if (n <= 1)
return -1;
--
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Come to the Red Hat TechWorld open source conference in Brussels!
Keynotes, techie talks and exhibitions http://www.redhat-techworld.com/
More information about the Newlib
mailing list