summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/config.c b/config.c
index 5eca17b242..788970c6bc 100644
--- a/config.c
+++ b/config.c
@@ -63,8 +63,12 @@ static int config_buf_fgetc(struct config_source *conf)
static int config_buf_ungetc(int c, struct config_source *conf)
{
- if (conf->u.buf.pos > 0)
- return conf->u.buf.buf[--conf->u.buf.pos];
+ if (conf->u.buf.pos > 0) {
+ conf->u.buf.pos--;
+ if (conf->u.buf.buf[conf->u.buf.pos] != c)
+ die("BUG: config_buf can only ungetc the same character");
+ return c;
+ }
return EOF;
}