From: Matthew Fernandez Date: Sun, 27 Nov 2022 19:24:35 +0000 (-0800) Subject: sfdpgen spring_electrical_embedding_slow: fix memory leak X-Git-Tag: 7.0.4~4^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb77944b47eef335310a459ade319d7770daf05b;p=graphviz sfdpgen spring_electrical_embedding_slow: fix memory leak `qtree_level_optimizer` would be optionally allocated based on `n >= ctrl->quadtree_size` but then would only be freed if `USE_QT` was set. `USE_QT` is always false (it will be removed in an upcoming commit), so this clean up never runs. This seems latent; I suspect the branch that allocates `qtree_level_optimizer` is unreachable because this function appears to have been copy-pasted from one of the other variants in this file with little regard to how much of it is dead code. But it still seems wise to fix this issue. --- diff --git a/lib/sfdpgen/spring_electrical.c b/lib/sfdpgen/spring_electrical.c index 6f7aee651..6d7642003 100644 --- a/lib/sfdpgen/spring_electrical.c +++ b/lib/sfdpgen/spring_electrical.c @@ -869,9 +869,9 @@ static void spring_electrical_embedding_slow(int dim, SparseMatrix A0, spring_el RETURN: if (USE_QT) { - oned_optimizer_delete(qtree_level_optimizer); ctrl->max_qtree_level = max_qtree_level; } + oned_optimizer_delete(qtree_level_optimizer); free(xold); if (A != A0) SparseMatrix_delete(A); free(f);