From 4fce02bc39701cebd482a53fffcd267c5ae1839a Mon Sep 17 00:00:00 2001 From: Tamas Nepusz Date: Wed, 21 Aug 2024 10:36:14 +0200 Subject: [PATCH] fix: fix a potential memory leak in Graph.get_shortest_path_astar()'s heuristic function --- src/_igraph/graphobject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/_igraph/graphobject.c b/src/_igraph/graphobject.c index 6322969fa..97ba1be64 100644 --- a/src/_igraph/graphobject.c +++ b/src/_igraph/graphobject.c @@ -5671,6 +5671,7 @@ igraph_error_t igraphmodule_i_Graph_get_shortest_path_astar_callback( to_o = igraphmodule_integer_t_to_PyObject(to); if (to_o == NULL) { /* Error in conversion, return 1 */ + Py_DECREF(from_o); return IGRAPH_FAILURE; } @@ -5685,9 +5686,11 @@ igraph_error_t igraphmodule_i_Graph_get_shortest_path_astar_callback( if (igraphmodule_PyObject_to_real_t(result_o, result)) { /* Error in conversion, return 1 */ + Py_DECREF(result_o); return IGRAPH_FAILURE; } + Py_DECREF(result_o); return IGRAPH_SUCCESS; }