summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ftell.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-08-31 20:17:32 +0000
committerache <ache@FreeBSD.org>2001-08-31 20:17:32 +0000
commit689eee076f9dc44bf46949caa22febf4436f3844 (patch)
tree104b91d26a1a0d36d2939921a4dd77f59cf77876 /lib/libc/stdio/ftell.c
parent8a7c2ca9e29e3d093b095a78f683db9d0e05f1a4 (diff)
downloadFreeBSD-src-689eee076f9dc44bf46949caa22febf4436f3844.zip
FreeBSD-src-689eee076f9dc44bf46949caa22febf4436f3844.tar.gz
Simplify offset underflow checks even more
Diffstat (limited to 'lib/libc/stdio/ftell.c')
-rw-r--r--lib/libc/stdio/ftell.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c
index a0b5fa8..9f1e106 100644
--- a/lib/libc/stdio/ftell.c
+++ b/lib/libc/stdio/ftell.c
@@ -114,8 +114,8 @@ get_real_pos:
* those from ungetc) cause the position to be
* smaller than that in the underlying object.
*/
- pos -= fp->_r;
- if (pos < 0) {
+ if ((pos -= fp->_r) < 0 ||
+ (HASUB(fp) && (pos -= fp->_ur) < 0)) {
fp->_p = fp->_bf._base;
fp->_r = 0;
if (HASUB(fp))
@@ -123,16 +123,6 @@ get_real_pos:
if (spos == -1)
goto get_real_pos;
pos = spos;
- } else if (HASUB(fp)) {
- pos -= fp->_ur;
- if (pos < 0) {
- fp->_p = fp->_bf._base;
- fp->_r = 0;
- FREEUB(fp);
- if (spos == -1)
- goto get_real_pos;
- pos = spos;
- }
}
} else if ((fp->_flags & __SWR) && fp->_p != NULL) {
/*
OpenPOWER on IntegriCloud