When fed Python objects of different types, pytalloc_default_cmp
compared pointers to PyType objects that weren't part of an array,
resulting in undefined behavior.
This makes things a bit better (though it still casts ptrdiff_t to int).
Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-By: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
pytalloc_Object *obj1 = (pytalloc_Object *)_obj1,
*obj2 = (pytalloc_Object *)_obj2;
if (obj1->ob_type != obj2->ob_type)
- return (obj1->ob_type - obj2->ob_type);
+ return ((char *)obj1->ob_type - (char *)obj2->ob_type);
return ((char *)pytalloc_get_ptr(obj1) - (char *)pytalloc_get_ptr(obj2));
}