diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-12-14 22:18:04 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-12-14 22:18:04 -0800 |
| commit | 94ba1fd177f28ef3d06f4aeb2e6044cb6c321992 (patch) | |
| tree | 858a7d1f37410af34b8126e2c6ab27d09730e340 /vm.c | |
| parent | 3acf397e6d772778490d7da9f33f3a8f939c9efd (diff) | |
Fixes for nodent in nested matches
Diffstat (limited to 'vm.c')
| -rw-r--r-- | vm.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -409,18 +409,19 @@ static match_t *_match(grammar_t *g, file_t *f, const char *str, vm_op_t *op, un size_t linenum = get_line_number(f, str); const char *p = get_line(f, linenum); + if (p < f->contents) p=f->contents; // Can happen with recursive matching // Current indentation: char denter = *p; int dents = 0; if (denter == ' ' || denter == '\t') { - for (; *p == denter; ++p) ++dents; + for (; *p == denter && p < f->end; ++p) ++dents; } // Subsequent indentation: while (*str == '\n') ++str; for (int i = 0; i < dents; i++) { - if (str[i] != denter) return NULL; + if (str[i] != denter || &str[i] >= f->end) return NULL; } match_t *m = calloc(sizeof(match_t), 1); |
