This pull request addresses a potential memory leak and improves error handling in the find_interface_by_number function within tcpdump.c. The issue was identified when the pcap_findalldevs or pcap_findalldevs_ex function call failed, leading to an early exit without freeing the allocated memory for the device list (devlist). This pull request ensures proper memory management by freeing resources before exiting the function on error.
What and Why
This pull request addresses a potential memory leak and improves error handling in the
find_interface_by_number
function withintcpdump.c
. The issue was identified when thepcap_findalldevs
orpcap_findalldevs_ex
function call failed, leading to an early exit without freeing the allocated memory for the device list (devlist
). This pull request ensures proper memory management by freeing resources before exiting the function on error.