diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2018-08-28 14:17:09 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2018-08-28 14:21:10 +0100 |
commit | 7a702103b4490e370b36587c34b8b549a75ef3a5 (patch) | |
tree | 9bc8cd57f15aa794ddc5e5ca60e134170ce81bed | |
parent | 4b00990640258f464b02ce3f721a22fcb59b289b (diff) |
Bug 699678: don't allow bytes to be "unread" from stdin
-rw-r--r-- | base/stream.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/base/stream.c b/base/stream.c index 815935827..68e119fd7 100644 --- a/base/stream.c +++ b/base/stream.c @@ -499,7 +499,11 @@ spputc(register stream * s, byte b) int sungetc(register stream * s, byte c) { - if (!s_is_reading(s) || s->srptr < s->cbuf || *(s->srptr) != c) + /* cbuf == NULL means this stream is stdin, and we shouldn't + unread from stdin, ever. + */ + if (s->cbuf == NULL || !s_is_reading(s) || + s->srptr < s->cbuf || *(s->srptr) != c) return ERRC; s->srptr--; return 0; |