summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-15 04:51:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-03-15 04:51:02 -0700
commit2aff577f5cffcf0cf3ca31b939443fad4b304977 (patch)
tree89c6e6aa29add8806a0b335013f642278074dc1c /stream.c
parent6737b7efe2f4ef7ad4e8f6b2716ada469ef3913d (diff)
downloadtxr-2aff577f5cffcf0cf3ca31b939443fad4b304977.tar.gz
txr-2aff577f5cffcf0cf3ca31b939443fad4b304977.tar.bz2
txr-2aff577f5cffcf0cf3ca31b939443fad4b304977.zip
Bugfix: set errno to zero in stdio_unget_byte.
* stream.c (stdio_unget_byte): Set errno to zero before ungetc, because ungetc probably almost certainly doesn't set errno when it fails.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/stream.c b/stream.c
index 60247af7..e9ba359b 100644
--- a/stream.c
+++ b/stream.c
@@ -719,6 +719,7 @@ static val stdio_unget_byte(val stream, int byte)
{
struct stdio_handle *h = coerce(struct stdio_handle *, stream->co.handle);
+ errno = 0;
return h->f != 0 && ungetc(byte, coerce(FILE *, h->f)) != EOF
? num_fast(byte)
: stdio_maybe_error(stream, lit("pushing back byte into"));