From 43b44bc5ad877a2244750ba721142cae0a35d20b Mon Sep 17 00:00:00 2001 From: Jonathan Larmour Date: Mon, 11 Jun 2001 17:21:18 +0000 Subject: * libc/stdlib/mbtowc_r.c (_mbtowc_r): Avoid dereferencing NULL pointer. --- newlib/libc/stdlib/mbtowc_r.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'newlib/libc/stdlib') diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c index 7d718c8b0..4bf302359 100644 --- a/newlib/libc/stdlib/mbtowc_r.c +++ b/newlib/libc/stdlib/mbtowc_r.c @@ -68,9 +68,10 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state), { /* 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]; @@ -87,9 +88,10 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state), } 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]; -- cgit v1.2.3