8000 fix UBSan failures for `DirEntry` · python/cpython@f53e72a · GitHub
[go: up one dir, main page]

Skip to content

Commit f53e72a

Browse files
committed
fix UBSan failures for DirEntry
1 parent 36bb229 commit f53e72a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Modules/posixmodule.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15523,9 +15523,12 @@ typedef struct {
1552315523
#endif
1552415524
} DirEntry;
1552515525

15526+
#define DirEntry_CAST(op) ((DirEntry *)(op) AC16 )
15527+
1552615528
static void
15527-
DirEntry_dealloc(DirEntry *entry)
15529+
DirEntry_dealloc(PyObject *op)
1552815530
{
15531+
DirEntry *entry = DirEntry_CAST(op);
1552915532
PyTypeObject *tp = Py_TYPE(entry);
1553015533
Py_XDECREF(entry->name);
1553115534
Py_XDECREF(entry->path);
@@ -15854,8 +15857,9 @@ os_DirEntry_inode_impl(DirEntry *self)
1585415857
}
1585515858

1585615859
static PyObject *
15857-
DirEntry_repr(DirEntry *self)
15860+
DirEntry_repr(PyObject *op)
1585815861
{
15862+
DirEntry *self = DirEntry_CAST(op);
1585915863
return PyUnicode_FromFormat("<DirEntry %R>", self->name);
1586015864
}
1586115865

0 commit comments

Comments
 (0)
0