From 1ec7a92679211417cf5d59c2342e160ed112d3e8 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 7 May 2017 17:04:56 +0300 Subject: ragel.rl: Add some asserts to confirm input Just some hardening: p should always be equal or behind pe. --- src/ragel/ragel.rl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') 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); } -- cgit v1.2.3-70-g09d2