mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Check RefCon backpointer to python object with IsPointerValid() before dereferencing it (carbon only).
This commit is contained in:
parent
26e51e1e83
commit
c54be4299c
2 changed files with 4 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
|||
#define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
|
||||
#define GetWindowFromPort(port) ((WindowRef)(port))
|
||||
#define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
|
||||
#define IsPointerValid(p) (((long)p&3) == 0)
|
||||
#endif
|
||||
#if ACCESSOR_CALLS_ARE_FUNCTIONS
|
||||
/* Classic calls that we emulate in carbon mode */
|
||||
|
@ -3038,7 +3039,7 @@ WinObj_WhichWindow(w)
|
|||
Py_INCREF(it);
|
||||
} else {
|
||||
it = (PyObject *) GetWRefCon(w);
|
||||
if (it == NULL || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
|
||||
if (it == NULL || !IsPointerValid((Ptr)it) || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
|
||||
it = WinObj_New(w);
|
||||
((WindowObject *)it)->ob_freeit = NULL;
|
||||
} else {
|
||||
|
|
|
@ -61,6 +61,7 @@ includestuff = includestuff + """
|
|||
#define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag)
|
||||
#define GetWindowFromPort(port) ((WindowRef)(port))
|
||||
#define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect)
|
||||
#define IsPointerValid(p) (((long)p&3) == 0)
|
||||
#endif
|
||||
#if ACCESSOR_CALLS_ARE_FUNCTIONS
|
||||
/* Classic calls that we emulate in carbon mode */
|
||||
|
@ -91,7 +92,7 @@ WinObj_WhichWindow(w)
|
|||
Py_INCREF(it);
|
||||
} else {
|
||||
it = (PyObject *) GetWRefCon(w);
|
||||
if (it == NULL || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
|
||||
if (it == NULL || !IsPointerValid((Ptr)it) || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
|
||||
it = WinObj_New(w);
|
||||
((WindowObject *)it)->ob_freeit = NULL;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue