From d14e9357869692f6221b64554f664b6430e21bc4 Mon Sep 17 00:00:00 2001 From: Johannes Kauffmann Date: Tue, 23 Jan 2024 09:22:49 +0100 Subject: [PATCH] slaveinfo: fix linked list leak Don't overwrite the original pointer returned by ec_find_adapters(), otherwise the linked list is leaked. Instead, use a temporary variable, and pass the original pointer to ec_free_adapters(). --- test/linux/slaveinfo/slaveinfo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/linux/slaveinfo/slaveinfo.c b/test/linux/slaveinfo/slaveinfo.c index 88558b18..5161d732 100644 --- a/test/linux/slaveinfo/slaveinfo.c +++ b/test/linux/slaveinfo/slaveinfo.c @@ -711,14 +711,16 @@ int main(int argc, char *argv[]) } else { + ec_adaptert * node; printf("Usage: slaveinfo ifname [options]\nifname = eth0 for example\nOptions :\n -sdo : print SDO info\n -map : print mapping\n"); printf ("Available adapters\n"); adapter = ec_find_adapters (); - while (adapter != NULL) + node = adapter; + while (node != NULL) { - printf ("Description : %s, Device to use for wpcap: %s\n", adapter->desc,adapter->name); - adapter = adapter->next; + printf ("Description : %s, Device to use for wpcap: %s\n", node->desc,node->name); + node = node->next; } ec_free_adapters(adapter); }