Fix Valgrind errors
cover Fix Valgrind errors
Running the ELL test suite through Valgrind triggers a few errors. This set of patches addresses three of those errors.
Ossama Othman (3):
dhcp-server: Fix memory leak.
unit: Free l_uintset when done.
unit: Initialize variables prior to use
ell/dhcp-server.c | 1 + unit/test-rtnl.c | 2 +- unit/test-uintset.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.32.0
PATCH 1/3 dhcp-server: Fix memory leak.
When adding a lease, free the dns field of a l_dhcp_lease instance prior to updating it. This addresses a memory leak found when running the test-dhcp unit test through the Valgrind memcheck tool.
--- ell/dhcp-server.c | 1 + 1 file changed, 1 insertion(+)
ell/dhcp-server.c +1 -0
@@ -308,6 +308,7 @@ static struct l_dhcp_lease *add_lease(struct l_dhcp_server *server,if (ret !=0 )return NULL ; +l_free (lease->dns);l_free (lease->client_id);memset (lease,0 ,sizeof (*lease));
Signature · 1 line
2.32.0
PATCH 2/3 unit: Free l_uintset when done.
In reply to Ossama OthmanIn the test_uintset_size() test case, free the l_uintset instance when done to fix a memory leak.
--- unit/test-uintset.c | 2 ++ 1 file changed, 2 insertions(+)
unit/test-uintset.c +2 -0
@@ -384,6 +384,8 @@ static void test_uintset_size(const void *user_data)assert (l_uintset_take (set, i));assert (l_uintset_size (set) ==0 ); + +l_uintset_free (set); }int main (int argc,char *argv[])
Signature · 1 line
2.32.0
PATCH 3/3 unit: Initialize variables prior to use
In reply to Ossama OthmanAddress "use of uninitialized variable" related error exhibited by Valgrind in the test-rtnl unit test.
--- unit/test-rtnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
unit/test-rtnl.c +1 -1
@@ -147,7 +147,7 @@ static void route6_dump_cb(int error, {const struct rtmsg *rtmsg = data;char *dst =NULL , *gateway =NULL , *src =NULL ; -uint32_t table, ifindex; +uint32_t table =0 , ifindex =0 ;test_assert (!error);test_assert (type ==RTM_NEWROUTE );
Signature · 1 line
2.32.0
Hi Ossama,
Quoted 8 lines · Ossama Othman
Running the ELL test suite through Valgrind triggers a few errors. This set of patches addresses three of those errors.
Ossama Othman (3):
dhcp-server: Fix memory leak.
unit: Freel_uintsetwhen done.
unit: Initialize variables prior to use
All applied, thanks.
Regards,
-Denis