On Tue, 27 Jul 2021 18:30:33 +0200 Damian Wrobel <dwro...@ertelnet.rybnik.pl> wrote:
> The returned pointer has to be freed by the caller not by the callee > function itself. So, this predates the public release, but long ago, that was indeed how it worked, and then LONG ago it was changed so that the pseudo_ipc stuff always used the same object for its returns, so we weren't doing alloc/free cycles all the time. Which means that, in every *other* code path, if we return a non-nil msg, it *must not* be freed. I think probably the solution is to change that object to be static. We can't make callers free the results unless we want them ALL to be freed, which we absolutely don't, that's devastatingly expensive. There is exactly one call with OP_CHROOT, and all it checks is whether the return is null or not-null. I'd be mildly surprised by the theoretically-invalid address of stack garbage actually causing a problem on most modern systems, except that I think some systems have started doing stack guards. But all we care about here is that the address returned be a valid non-null pointer. Heck, we could use &xattrdb_data, that already exists, is already static, and we don't care about it. (The reason the `msg` in that function isn't static is so it gets its initializer every time. This is not a great reason.) -s
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#154176): https://lists.openembedded.org/g/openembedded-core/message/154176 Mute This Topic: https://lists.openembedded.org/mt/84479678/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-