Skip to content

Commit b92c34a

Browse files
committed
Avoid memcpy in bytecodes.c
1 parent a2abc7e commit b92c34a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Include/internal/pycore_frame.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ _PyFrame_NumSlotsForCodeObject(PyCodeObject *code)
113113
static inline void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest)
114114
{
115115
assert(src->stacktop >= _PyFrame_GetCode(src)->co_nlocalsplus);
116-
Py_ssize_t size = ((char*)&src->localsplus[src->stacktop]) - (char *)src;
117-
memcpy(dest, src, size);
116+
*dest = *src;
117+
for (int i = 1; i < src->stacktop; i++) {
118+
dest->localsplus[i] = src->localsplus[i];
119+
}
118120
// Don't leave a dangling pointer to the old frame when creating generators
119121
// and coroutines:
120122
dest->previous = NULL;

0 commit comments

Comments
 (0)