1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-19 10:53:58 +00:00

Add mbstate clear missed in one of the cases.

Move overflow check for fseek as early as needed.
This commit is contained in:
Andrey A. Chernov 2007-06-18 02:09:08 +00:00
parent 9e897b1bc6
commit ef0fddb70d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=170907

View File

@ -283,6 +283,7 @@ _fseeko(fp, offset, whence, ltest)
fp->_r -= n; fp->_r -= n;
} }
fp->_flags &= ~__SEOF; fp->_flags &= ~__SEOF;
memset(&fp->_extra->mbstate, 0, sizeof(mbstate_t));
return (0); return (0);
/* /*
@ -293,6 +294,11 @@ _fseeko(fp, offset, whence, ltest)
if (__sflush(fp) || if (__sflush(fp) ||
(ret = _sseek(fp, (fpos_t)offset, whence)) == POS_ERR) (ret = _sseek(fp, (fpos_t)offset, whence)) == POS_ERR)
return (-1); return (-1);
if (ltest && ret > LONG_MAX) {
fp->_flags |= __SERR;
errno = EOVERFLOW;
return (-1);
}
/* success: clear EOF indicator and discard ungetc() data */ /* success: clear EOF indicator and discard ungetc() data */
if (HASUB(fp)) if (HASUB(fp))
FREEUB(fp); FREEUB(fp);
@ -301,10 +307,5 @@ _fseeko(fp, offset, whence, ltest)
/* fp->_w = 0; */ /* unnecessary (I think...) */ /* fp->_w = 0; */ /* unnecessary (I think...) */
fp->_flags &= ~__SEOF; fp->_flags &= ~__SEOF;
memset(&fp->_extra->mbstate, 0, sizeof(mbstate_t)); memset(&fp->_extra->mbstate, 0, sizeof(mbstate_t));
if (ltest && ret > LONG_MAX) {
fp->_flags |= __SERR;
errno = EOVERFLOW;
return (-1);
}
return (0); return (0);
} }