GNOME Bugzilla – Bug 616043
Set all out arguments to a known bad pointer and check for it
Last modified: 2010-04-26 16:30:53 UTC
PyGI should set all out arguments by default to some known value, such as the address of _wrap_g_info_function_invoke_, and then before we do something like try and free the out arguments we check to make sure they are not NULL and not that address. This is to protect against library bugs where they leave out arguments dangling instead of setting them to NULL.
Any complaints if I just do *out_var = NULL; and then check for NULL later? I'm thinking about this more now and I don't see any reason why we need a specific address/
Created attachment 159228 [details] [review] Force out arguments to be initialized as NULL. Comes with a test. This fix was motivated by a real world library which had a transfer full utf8 out argument which sometimes was not set. We would leave the pointer dangling and try and free it at the end of invoke() and crash. Library refused to change their behavior so we're forced to take care of it on our end.
*bump* :)
Review of attachment 159228 [details] [review]: Great!
Attachment 159228 [details] pushed as 8240320 - Force out arguments to be initialized as NULL. Comes with a test.