groupsolver: fix segfault accessing solver->names.

Reproduced via 'groupsolver -v 5i:l5_2b5h' (thanks to Arun Giridhar
for the report).

We had filled in subsolver.names, but then called
latin_solver_alloc(&subsolver), which nulled out that pointer again.

Solution: do those two things in the opposite order.
This commit is contained in:
Simon Tatham
2024-12-22 11:55:50 +00:00
parent 5099e4c6d4
commit 59954d67f5

View File

@ -819,17 +819,18 @@ static int latin_solver_recurse
} else { } else {
newctx = ctx; newctx = ctx;
} }
if (latin_solver_alloc(&subsolver, outgrid, o)) {
#ifdef STANDALONE_SOLVER #ifdef STANDALONE_SOLVER
subsolver.names = solver->names; subsolver.names = solver->names;
#endif #endif
if (latin_solver_alloc(&subsolver, outgrid, o))
ret = latin_solver_top(&subsolver, diff_recursive, ret = latin_solver_top(&subsolver, diff_recursive,
diff_simple, diff_set_0, diff_set_1, diff_simple, diff_set_0, diff_set_1,
diff_forcing, diff_recursive, diff_forcing, diff_recursive,
usersolvers, valid, newctx, usersolvers, valid, newctx,
ctxnew, ctxfree); ctxnew, ctxfree);
else } else {
ret = diff_impossible; ret = diff_impossible;
}
latin_solver_free(&subsolver); latin_solver_free(&subsolver);
if (ctxnew) if (ctxnew)
ctxfree(newctx); ctxfree(newctx);