regexec(): use regtry(&s) not regtry(&startpos)
authorDavid Mitchell <davem@iabyn.com>
Fri, 19 Jul 2013 15:37:04 +0000 (16:37 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 28 Jul 2013 09:33:39 +0000 (10:33 +0100)
commit3542935d7265972713626cf9f6a19e67554be369
tree8ed377d17fc7a0cef2dbdbbf318ee88be023f303
parentd5e7783a3e8dcf16e8d64aae0d77eed33dc12a5c
regexec(): use regtry(&s) not regtry(&startpos)

regexec() has several cases such as anchored, floating etc, and for each
of these it will call regtry() one or more times to match at likely
starting positions. In all cases but one, it calls regtry(&s), where
s is the current start position that moves as we try new positions. In
the one final case it uses startpos instead, which is supposed to be static.
The actual code looks like:

    if (s == startpos && regtry(&startpos))

which might seem harmless, but under things like (*COMMIT), regtry can
update the pointer value (which is why its address is taken). So in this
(obscure) case, the wrong pointer gets updated.
regexec.c
t/re/pat_advanced.t