mirror of https://github.com/Gnucash/gnucash
The collection_compare_cb function set the user_data pointer to point to a local variable of the function. That pointer is then used in the (only) calling function qof_collection_compare to make decisions. This is undefined. It is likely not an actual problem because the stack depth of the qof_collection_foreach followed by collection_compare_cb is deeper than the qof_collection_get_data call (and others in between if any) that the stack data user data stays uncorrupted. But, it is undefined behavior, and could cause really subtle bugs if these there are code changes that have deeper stack between the setting and using. Also, using this local variable is not necessary, the qof_collection_compare function already sets up a variable local to its scope for this that the collection_compare_cb can use directly. This commit removes the local (to collection_compare_cb) variable and uses the one setup in qof_collection_compare. The full coverage test for qofid.cpp passed before and after this change.pull/2169/head
parent
6e9a20dfeb
commit
0e3853bfb7
Loading…
Reference in new issue