twekkel / htpdate

HTTP Time protocol
https://www.vervest.org/htp
Other
50 stars 13 forks source link

Memory leak from strdup when proxy is enabled #32

Open vikivivi opened 10 months ago

vikivivi commented 10 months ago

It seem there is a memory leak when using strdup(), the memory is not free.

https://github.com/twekkel/htpdate/blob/master/htpdate.c#L831

twekkel commented 10 months ago

Thanks for taking the time to investigate. I'm aware of it, but there is no real leak... let me explain. The proxy setting (=strdup) is a one-time thing and is needed as long as the program is running. Freeing before the program terminates is not possible. So the tooling is right, the strdup() doesn't have a corresponding free(), but then again it is not possible either.

To satisfy tooling (I used Valgrind in the past), you can scan the NoLeak branch. If you look at the changes I made, you will also see that the "fix" is pointless.