attractivechaos / klib

A standalone and lightweight C library
http://attractivechaos.github.io/klib/
MIT License
4.18k stars 556 forks source link

Fixing a memory leak in knetfile.c. #104

Open timothy-king opened 6 years ago

timothy-king commented 6 years ago

fp->size_cmd is set to allocated memory in kftp_parse_url() but this is not freed by knet_close(). The fix should be safe in other cases as these allocate the memory of fp via calloc leaving fp->size_cmd equal to NULL by default, and free(NULL) is a nop (https://linux.die.net/man/3/free).

Adds a test that builds knetfile.c.

timothy-king commented 6 years ago

If the test for that builds knetfile.c is too instrusive/hackish, it can be dropped.