mirror of
https://github.com/pytorch/pytorch.git
synced 2025-11-03 15:35:04 +08:00
Fix segfault in has_torch_function (#88559)
Fixes #83908 `PySequence_Fast` may return `NULL` to indicate an error was raised, in which case `sequence_has_torch_function` will dereference a null pointer. Pull Request resolved: https://github.com/pytorch/pytorch/pull/88559 Approved by: https://github.com/ezyang, https://github.com/Skylion007, https://github.com/hameerabbasi
This commit is contained in:
committed by
PyTorch MergeBot
parent
4796e23bbb
commit
eb3f975c6e
@ -263,6 +263,9 @@ PyObject* THPModule_has_torch_function(PyObject*, PyObject* arg) {
|
||||
} else {
|
||||
auto args = py::reinterpret_steal<py::object>(
|
||||
PySequence_Fast(arg, "expected a sequence"));
|
||||
if (!args) {
|
||||
return nullptr;
|
||||
}
|
||||
result = sequence_has_torch_function(args.ptr());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user