summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2017-05-07 17:04:56 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2017-05-07 17:05:31 +0300
commit1ec7a92679211417cf5d59c2342e160ed112d3e8 (patch)
tree8c578e5b68abc2f9fa74810ba2a4f18fe1d37329
parent8087a503f00913fc7b26e75d9549f6b99adf3242 (diff)
ragel.rl: Add some asserts to confirm input
Just some hardening: p should always be equal or behind pe.
-rw-r--r--src/ragel/ragel.rl3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ragel/ragel.rl b/src/ragel/ragel.rl
index 655bb9c..4974bd5 100644
--- a/src/ragel/ragel.rl
+++ b/src/ragel/ragel.rl
@@ -32,6 +32,7 @@ ragel_exec_error(const struct ragel *ragel, const int start_cs, const char **err
assert(ragel && ragel->cl && error);
int cs = start_cs;
const char *p = ragel->cl, *pe = ragel->pe, *eof = ragel->eof;
+ assert(p <= pe);
%% write exec;
}
@@ -47,6 +48,7 @@ ragel_throw_error(struct ragel *ragel, const char *fmt, ...)
ragel_exec_error(ragel, ragel_en_search_err, &error);
const char *name = (ragel->name ? ragel->name : "");
+ assert(error >= ragel->cl);
uint64_t column = (error - ragel->cl);
fprintf(stderr, "\x1b[37m%s:%" PRIu64 ":%" PRIu64 " \x1b[31merror: \x1b[0m", name, ragel->lineno, column);
@@ -85,4 +87,5 @@ ragel_feed_input(struct ragel *ragel, const bool eof, const struct ragel_mem *in
ragel->cl = ragel->p = ragel->input.data;
ragel->pe = ragel->input.end;
ragel->eof = (eof ? ragel->pe : NULL);
+ assert(ragel->p <= ragel->pe);
}