Fix string leak in aegisub.ffi#558
Conversation
type(cdata) always returns 'cdata', the correct function to use is ffi.typeof
|
Thanks! And no, I don't think (To be honest, I also don't know why most of Aegisub's lua modules use ffi in the first place. The modules were refactored to using ffi in 2014 but I can't see any reasoning for it in the commit. It may be a bit faster and/or get rid of some boilerplate code, but it has the big disadvantage of locking Aegisub into a strict luajit dependency that cannot be replaced with normal lua. But figuring this out and potentially improving this has been quite low priority for me so far given all the other issues.) |
We might consider moving it to |
This function leaks the string passed to it:
This is because the const check is broken as
type(cdata)just returns'cdata'(the correct function isffi.typeof).Are we sure we want this function (and the whole
aegisub.ffimodule) to be exposed to automation scripts? I don't think it's supposed to be public API, but it's still possible to use it from scripts. It doesn't seem anyone actually uses it, but if someone in fact does and relies on the broken behavior, they're going to have a lot of fun debugging double frees.Leak found by LSan: