mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
PE's block module: Use sip.voidptr's ascapsule() instead of __int__() to retrieve its pointer.
It caused crashes under 32 bits when pointers would flip our long's most significant bit. (Well, at least that's what I think was going on).
This commit is contained in:
parent
392a802ef1
commit
64baf2a10c
@ -35,7 +35,7 @@ getblock(PyObject *image, int width, int height)
|
|||||||
red = green = blue = 0;
|
red = green = blue = 0;
|
||||||
pixel_count = width * height;
|
pixel_count = width * height;
|
||||||
if (pixel_count) {
|
if (pixel_count) {
|
||||||
PyObject *sipptr, *pi;
|
PyObject *sipptr, *bits_capsule, *pi;
|
||||||
char *s;
|
char *s;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -44,11 +44,10 @@ getblock(PyObject *image, int width, int height)
|
|||||||
Py_DECREF(pi);
|
Py_DECREF(pi);
|
||||||
|
|
||||||
sipptr = PyObject_CallMethod(image, "bits", NULL);
|
sipptr = PyObject_CallMethod(image, "bits", NULL);
|
||||||
/* int(sipptr) returns the address of the pointer */
|
bits_capsule = PyObject_CallMethod(sipptr, "ascapsule", NULL);
|
||||||
pi = PyObject_CallMethod(sipptr, "__int__", NULL);
|
|
||||||
Py_DECREF(sipptr);
|
Py_DECREF(sipptr);
|
||||||
s = (char *)PyLong_AsLong(pi);
|
s = (char *)PyCapsule_GetPointer(bits_capsule, NULL);
|
||||||
Py_DECREF(pi);
|
Py_DECREF(bits_capsule);
|
||||||
/* Qt aligns all its lines on 32bit, which means that if the number of bytes per
|
/* Qt aligns all its lines on 32bit, which means that if the number of bytes per
|
||||||
* line for image is not divisible by 4, there's going to be crap inserted in "s"
|
* line for image is not divisible by 4, there's going to be crap inserted in "s"
|
||||||
* We have to take this into account when calculating offsets
|
* We have to take this into account when calculating offsets
|
||||||
|
Loading…
x
Reference in New Issue
Block a user