🌐 AI搜索 & 代理 主页
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG: Avoid segfault when calling `numpy._core.strings._expandtabs_len…
…gth.reduce`

Fixes the first item of #28829. Use `Py_XINCREF` instead of `Py_INCREF` to safely handle the case where `op_dtypes[0]` is NULL
  • Loading branch information
riku-sakamoto authored and charris committed Oct 10, 2025
commit 7819364b563ede5091c3f7d803d1684a15b41f40
2 changes: 1 addition & 1 deletion numpy/_core/src/umath/string_ufuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ string_expandtabs_length_promoter(PyObject *NPY_UNUSED(ufunc),
PyArray_DTypeMeta *const op_dtypes[], PyArray_DTypeMeta *const signature[],
PyArray_DTypeMeta *new_op_dtypes[])
{
Py_INCREF(op_dtypes[0]);
Py_XINCREF(op_dtypes[0]);
new_op_dtypes[0] = op_dtypes[0];
new_op_dtypes[1] = NPY_DT_NewRef(&PyArray_Int64DType);
new_op_dtypes[2] = PyArray_DTypeFromTypeNum(NPY_DEFAULT_INT);
Expand Down