summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r--Objects/codeobject.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index ad8f13a..8de5c4d 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -656,15 +656,13 @@ _PyCode_Addr2Offset(PyCodeObject* co, int addrq)
if (co->co_columntable == Py_None || addrq < 0) {
return -1;
}
- if (addrq % 2 == 1) {
- --addrq;
- }
- if (addrq >= PyBytes_GET_SIZE(co->co_columntable)) {
+ addrq /= sizeof(_Py_CODEUNIT);
+ if (addrq*2 >= PyBytes_GET_SIZE(co->co_columntable)) {
return -1;
}
unsigned char* bytes = (unsigned char*)PyBytes_AS_STRING(co->co_columntable);
- return bytes[addrq] - 1;
+ return bytes[addrq*2] - 1;
}
int
@@ -673,15 +671,13 @@ _PyCode_Addr2EndOffset(PyCodeObject* co, int addrq)
if (co->co_columntable == Py_None || addrq < 0) {
return -1;
}
- if (addrq % 2 == 0) {
- ++addrq;
- }
- if (addrq >= PyBytes_GET_SIZE(co->co_columntable)) {
+ addrq /= sizeof(_Py_CODEUNIT);
+ if (addrq*2+1 >= PyBytes_GET_SIZE(co->co_columntable)) {
return -1;
}
unsigned char* bytes = (unsigned char*)PyBytes_AS_STRING(co->co_columntable);
- return bytes[addrq] - 1;
+ return bytes[addrq*2+1] - 1;
}
void