@@ -476,6 +476,7 @@ PyArray_CheckCastSafety(NPY_CASTING casting,
476
476
477
477
if (PyArray_MinCastSafety (castingimpl -> casting , casting ) == casting ) {
478
478
/* No need to check using `castingimpl.resolve_descriptors()` */
479
+ Py_DECREF (meth );
479
480
return 1 ;
480
481
}
481
482
@@ -1648,14 +1649,14 @@ PyArray_ResultType(
1648
1649
Py_DECREF (all_DTypes [i ]);
1649
1650
}
1650
1651
if (common_dtype == NULL ) {
1651
- goto finish ;
1652
+ goto error ;
1652
1653
}
1653
1654
1654
1655
if (common_dtype -> abstract ) {
1655
1656
/* (ab)use default descriptor to define a default */
1656
1657
PyArray_Descr * tmp_descr = common_dtype -> default_descr (common_dtype );
1657
1658
if (tmp_descr == NULL ) {
1658
- goto finish ;
1659
+ goto error ;
1659
1660
}
1660
1661
Py_INCREF (NPY_DTYPE (tmp_descr ));
1661
1662
Py_SETREF (common_dtype , NPY_DTYPE (tmp_descr ));
@@ -1688,20 +1689,18 @@ PyArray_ResultType(
1688
1689
PyObject * tmp = PyArray_GETITEM (
1689
1690
arrs [i - ndtypes ], PyArray_BYTES (arrs [i - ndtypes ]));
1690
1691
if (tmp == NULL ) {
1691
- Py_SETREF (result , NULL );
1692
- goto finish ;
1692
+ goto error ;
1693
1693
}
1694
1694
curr = common_dtype -> discover_descr_from_pyobject (common_dtype , tmp );
1695
1695
Py_DECREF (tmp );
1696
1696
}
1697
1697
if (curr == NULL ) {
1698
- Py_SETREF (result , NULL );
1699
- goto finish ;
1698
+ goto error ;
1700
1699
}
1701
1700
Py_SETREF (result , common_dtype -> common_instance (result , curr ));
1702
1701
Py_DECREF (curr );
1703
1702
if (result == NULL ) {
1704
- goto finish ;
1703
+ goto error ;
1705
1704
}
1706
1705
}
1707
1706
}
@@ -1722,16 +1721,21 @@ PyArray_ResultType(
1722
1721
* Going from error to success should not really happen, but is
1723
1722
* probably OK if it does.
1724
1723
*/
1725
- Py_SETREF (result , NULL );
1726
- goto finish ;
1724
+ goto error ;
1727
1725
}
1728
1726
/* Return the old "legacy" result (could warn here if different) */
1729
1727
Py_SETREF (result , legacy_result );
1730
1728
}
1731
1729
1732
- finish :
1730
+ Py_DECREF ( common_dtype );
1733
1731
PyMem_Free (info_on_heap );
1734
1732
return result ;
1733
+
1734
+ error :
1735
+ Py_XDECREF (result );
1736
+ Py_XDECREF (common_dtype );
1737
+ PyMem_Free (info_on_heap );
1738
+ return NULL ;
1735
1739
}
1736
1740
1737
1741
0 commit comments