[Python-checkins] CVS: python/dist/src/Objects object.c,2.150,2.151
Guido van Rossum
gvanrossum@users.sourceforge.net
2001年9月20日 06:38:24 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv22476
Modified Files:
object.c
Log Message:
_PyObject_GetDictPtr(): when the offset is negative, always align --
we can't trust that tp_basicsize is aligned. Fixes SF bug #462848.
Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.150
retrieving revision 2.151
diff -C2 -d -r2.150 -r2.151
*** object.c 2001年09月18日 20:38:53 2.150
--- object.c 2001年09月20日 13:38:22 2.151
***************
*** 1151,1166 ****
if (dictoffset < 0) {
dictoffset += tp->tp_basicsize;
assert(dictoffset > 0); /* Sanity check */
! if (tp->tp_itemsize > 0) {
! int n = ((PyVarObject *)obj)->ob_size;
! if (n > 0) {
! dictoffset += tp->tp_itemsize * n;
! /* Round up, if necessary */
! if (tp->tp_itemsize % PTRSIZE != 0) {
! dictoffset += PTRSIZE - 1;
! dictoffset /= PTRSIZE;
! dictoffset *= PTRSIZE;
! }
! }
}
}
--- 1151,1161 ----
if (dictoffset < 0) {
dictoffset += tp->tp_basicsize;
+ dictoffset += tp->tp_itemsize * ((PyVarObject *)obj)->ob_size;
assert(dictoffset > 0); /* Sanity check */
! /* Round up, if necessary */
! if (dictoffset % PTRSIZE != 0) {
! dictoffset /= PTRSIZE;
! dictoffset += 1;
! dictoffset *= PTRSIZE;
}
}