Skip to content

Commit b1df7d9

Browse files
committed
pyrdb: casting null should return null
This fixes a crash when a type in a slotted hierarchy has no slots, like _socket.socket. Should generally make things better
1 parent ba91ef5 commit b1df7d9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎libpstack/pyrdb.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,10 @@ class Target {
330330

331331

332332
template<typename To> Remote<To *> Target::cast(const PyType<To> &to, Remote<PyObject *> from) const {
333-
if (pyType(from) == to.typeObject)
334-
return { reinterpret_cast<To *>(from.remote) };
333+
if (from) {
334+
if (pyType(from) == to.typeObject)
335+
return { reinterpret_cast<To *>(from.remote) };
336+
}
335337
return {0};
336338
}
337339

0 commit comments

Comments
 (0)