diff --git a/solver/solver.c b/solver/solver.c index fe1c66d07..75b1fa7a7 100644 --- a/solver/solver.c +++ b/solver/solver.c @@ -1358,6 +1358,12 @@ static void resolve_matches(kdtree_qres_t* krez, const double *field_xy, if (solver_handle_hit(solver, &mo, NULL, FALSE)) solver->quit_now = TRUE; + if (mo.sip != solver->best_match.sip) + { + sip_free(mo.sip); + mo.sip = NULL; + } + if (unlikely(solver->quit_now)) return; } diff --git a/solver/tweak2.c b/solver/tweak2.c index ee3150c46..5ace98f76 100644 --- a/solver/tweak2.c +++ b/solver/tweak2.c @@ -318,6 +318,7 @@ sip_t* tweak2(const double* fieldxy, int Nfield, free(fieldsigma2s); free(indexpix); free(indexin); + free(refperm); return NULL; } @@ -362,7 +363,7 @@ sip_t* tweak2(const double* fieldxy, int Nfield, W, H, distractors, logodds_bail, LARGE_VAL, &besti, &odds, &theta, NULL, - &testperm, &refperm); + NULL, &refperm); logverb("Logodds: %g\n", logodds); verify_count_hits(theta, besti, &nmatch, &nconf, &ndist); @@ -434,6 +435,7 @@ sip_t* tweak2(const double* fieldxy, int Nfield, free(fieldsigma2s); free(indexpix); free(indexin); + free(refperm); return NULL; } @@ -526,7 +528,7 @@ sip_t* tweak2(const double* fieldxy, int Nfield, W, H, distractors, logodds_bail, LARGE_VAL, &besti, &odds, &theta, NULL, - &testperm, &refperm); + NULL, &refperm); logverb("Logodds: %g\n", logodds); verify_count_hits(theta, besti, &nmatch, &nconf, &ndist); logverb("%i matches, %i distractors, %i conflicts (at best log-odds); %i field sources, %i index sources\n", nmatch, ndist, nconf, Nfield, Nin); diff --git a/util/simplexy.c b/util/simplexy.c index 8c47682f2..071d3e113 100644 --- a/util/simplexy.c +++ b/util/simplexy.c @@ -331,6 +331,8 @@ int simplexy_run(simplexy_t* s) { mask = malloc((size_t)nx*(size_t)ny); if (!dmask(smoothed, nx, ny, limit, s->dpsf, mask)) { FREEVEC(smoothfree); + FREEVEC(bgfree); + FREEVEC(mask); return 0; } FREEVEC(smoothfree);