diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-10-01 19:29:31 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-10-01 19:29:31 -0700 |
| commit | 0ad64a1006f10dcb6e431985f3c26816f50f64d1 (patch) | |
| tree | f10146ca8b6db5be0f775363a9628e541e33db04 /match.c | |
| parent | 73bbf6872a3ec5d9dd8d0d587b00056c59bcbd30 (diff) | |
Bugfix for use-after-free, as well as an issue with the order
grammars were loaded
Diffstat (limited to 'match.c')
| -rw-r--r-- | match.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -636,7 +636,8 @@ static match_t *match(match_ctx_t *ctx, const char *str, pat_t *pat) while (rec_op.args.leftrec.visits > 0) { rec_op.args.leftrec.visits = 0; - recycle_match(&rec_op.args.leftrec.match); + if (rec_op.args.leftrec.match && rec_op.args.leftrec.match != m) + recycle_match(&rec_op.args.leftrec.match); rec_op.args.leftrec.match = m; prev = m->end; match_t *m2 = match(&ctx2, str, ref); @@ -645,10 +646,11 @@ static match_t *match(match_ctx_t *ctx, const char *str, pat_t *pat) recycle_match(&m2); break; } + recycle_match(&m); m = m2; } - if (rec_op.args.leftrec.match) + if (rec_op.args.leftrec.match && rec_op.args.leftrec.match != m) recycle_match(&rec_op.args.leftrec.match); // This match wrapper mainly exists for record-keeping purposes. |
