summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-02-05 19:29:50 -0800
committerKaz Kylheku <kaz@kylheku.com>2020-02-05 19:29:50 -0800
commit87894bc6fd24045bac73590e412e5a292a195847 (patch)
tree6917cb057d1eb3d4c3cfc5d60b353a9e52cbce27
parentf99ed67ea0eba3ce858eaf845f179570cd0e585b (diff)
downloadtxr-87894bc6fd24045bac73590e412e5a292a195847.tar.gz
txr-87894bc6fd24045bac73590e412e5a292a195847.tar.bz2
txr-87894bc6fd24045bac73590e412e5a292a195847.zip
fill-buf/fill-buf-adjust: incorrect return value.
* stream.c (stdio_fill_buf): In the case of EOF, we must not return zero, but pos. Also, since pos and nread are cnum, we should use num to convert their sum to val. Converting to unum doesn't do anything for the overflow situation.
-rw-r--r--stream.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stream.c b/stream.c
index 3dd76a4d..0ca0f799 100644
--- a/stream.c
+++ b/stream.c
@@ -894,10 +894,10 @@ static val stdio_fill_buf(val stream, val buf, cnum pos)
if (h->f != 0) {
cnum nread = fread(ptr + pos, 1, len - pos, h->f);
if (nread > 0)
- return unum(pos + nread);
+ return num(pos + nread);
}
stdio_maybe_read_error(stream);
- return zero;
+ return num(pos);
}
static val stdio_close(val stream, val throw_on_error)