Created attachment 14774 [details]
Patch: use a wrapper function to limit the returned value
In talloc 21.1.15 and earlier versions, pytalloc_default_cmp and pytalloc_base_default_cmp implement Python comparison functions for talloc objects. These functions return the difference between two pointers.
This is wrong for a couple of reasons:
- These functions are meant to return only -1, 0 or 1 (see https://docs.python.org/2/c-api/typeobj.html). Recent versions of the Python runtime system enforce this and produce a warning -- "tp_compare didn't return -1, 0 or 1" -- when they're used.
- The return value is an int, which is smaller than ptrdiff_t on some platforms.
I've attached a patch which fixes this using a wrapper function.