Permalink
Browse files

Skeleton: fixed comparison of transition tags during construction.

At the time of skeleton construction DFA has just been build and
all tags in it are just raw pointers to lists of commands. These
pointers are unique for each transition (tags are not shared between
transitions). This means, comparing tags for different transitions
will always result in 'not equal', except if both transitions have
no tags (pointers are NULLs).

Found by slyfox's fuzzer. ;)
  • Loading branch information...
skvadrik committed Nov 18, 2016
1 parent 2db0433 commit 9e63260cebd72183c9401addbf21767edbe39176
Showing with 6 additions and 1 deletion.
  1. +6 −1 re2c/src/ir/skeleton/skeleton.cc
@@ -14,14 +14,19 @@ Node::Node()
, cmd(NULL)
{}
+static bool same(const tcmd_t &x, const tcmd_t &y)
+{
+ return x.save == y.save && x.copy == y.copy;
+}
+
void Node::init(const dfa_state_t *s, const charset_t &cs, size_t nil)
{
const size_t nc = cs.size() - 1;
for (uint32_t c = 0, l = 0; c < nc;) {
size_t j = s->arcs[c];
const tcmd_t &t = s->tcmd[c];
- for (; ++c < nc && s->arcs[c] == j && !s->tcmd[c].save && !s->tcmd[c].copy;);
+ for (; ++c < nc && s->arcs[c] == j && same(s->tcmd[c], t););
if (j == dfa_t::NIL) j = nil;
// all arcs go to default node => this node is final

0 comments on commit 9e63260

Please sign in to comment.