astrand / xclip

Command line interface to the X11 clipboard
GNU General Public License v2.0
1.03k stars 73 forks source link

Fix resource leak #104

Closed hwangcc23 closed 3 years ago

hwangcc23 commented 3 years ago

1). File handles from fopen should be closed by fclose after use. Free fil_handle in the function doIn after reading date from each file.

2). Memory allocated from xcmalloc/xcrealloc should be freed after use. Free file_names in the function doIn after reading data from all files.

hackerb9 commented 3 years ago

Thank you for catching the resource leak with fil_handle being repeatedly opened without being closed.

hwangcc23 commented 3 years ago

@hackerb9 I have updated the PR. Please help review the code again.