chiark / gitweb /
math/pgen.c: Don't free the tester if it's not set up.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 14 Nov 2019 19:46:53 +0000 (19:46 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 16 Dec 2019 16:25:25 +0000 (16:25 +0000)
commit8501f5f0126385c5c7fc58edd7a44dfd1c94ac6e
treedabcfc0300b4bf25eb9027b39e153e49bc690628
parentb67c17c38e660bbf6f68e23f27af5a974a3b08ac
math/pgen.c: Don't free the tester if it's not set up.

The problem flow is this:

  * The stepper reports a candidate (`p' is `P_STEP', and `proc' returns
    `PGEN_TRY').

  * We decide to (a) report an event (set `A_EVENT' in `act'), and (b)
    initialize the tester (set `p = P_TEST', `proc = test', and `rq =
    PGEN_BEGIN'.

  * We call the event handler, but it returns `PGEN_ABORT'.  We notice
    that `p == P_TEST', and set `A_ENDTEST'.

  * This causes us to call `test' with `PGEN_DONE'.  Alas, the tester
    hasn't been initialized, because we haven't actually called it with
    `PGEN_BEGIN' yet.  Result: segfault.

We can notice this because `rq == PGEN_BEGIN': don't set `A_ENDTEST'
if this is the case.
math/pgen.c