Closed precla closed 2 years ago
Hey, thanks for your report.
It looks a bit contrived but the logic checks out, I think. The idea is to have the function return whether or not something was dropped, and m
(after the implicit conversion to bool) does that, since m
will be non-NULL in that case (and we're making use of the fact that free(NULL)
is explicitly permitted here.
I agree it looks like a potential use-after-free though, and the return should probably read return !!m
instead, for clarity.
You're right about the value eventually not being used though -- turns out we don't really need it in the places it's used (essentially the PART and the KICK handlers). Can't hurt to have the mechanism, though.
Thanks again for the input!
https://github.com/fstd/libsrsirc/blob/e76c45dd0598cf28695eed12cb0d2e05f29cace9/libsrsirc/ucbase.c#L198
free(m)
then one line below isreturn m;
https://github.com/fstd/libsrsirc/blob/e76c45dd0598cf28695eed12cb0d2e05f29cace9/libsrsirc/ucbase.c#L199Return value is never used. Was
NULL
ortrue/false
maybe intended to be here or is this on purpose?(Found with cppcheck)