Skip to content

Commit

Permalink
slaveinfo: fix linked list leak
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
JohannesKauffmann committed Jan 23, 2024
1 parent fb6fe84 commit d14e935
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/linux/slaveinfo/slaveinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit d14e935

Please sign in to comment.