Skip to content

Commit a9bc5db

Browse files
authored
Merge pull request numpy#15503 from eric-wieser/do-not-allow-copyswap-noop
MAINT: Do not allow `copyswap` and friends to fail silently
2 parents 85be00a + a2c6c45 commit a9bc5db

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

numpy/core/src/multiarray/arraytypes.c.src

+6
Original file line numberDiff line numberDiff line change
@@ -2290,6 +2290,7 @@ static void
22902290
STRING_copyswapn (char *dst, npy_intp dstride, char *src, npy_intp sstride,
22912291
npy_intp n, int NPY_UNUSED(swap), PyArrayObject *arr)
22922292
{
2293+
assert(arr != NULL);
22932294
if (arr == NULL) {
22942295
return;
22952296
}
@@ -2304,6 +2305,7 @@ VOID_copyswapn (char *dst, npy_intp dstride, char *src, npy_intp sstride,
23042305
{
23052306
PyArray_Descr *descr;
23062307

2308+
assert(arr != NULL);
23072309
if (arr == NULL) {
23082310
return;
23092311
}
@@ -2394,6 +2396,7 @@ VOID_copyswap (char *dst, char *src, int swap, PyArrayObject *arr)
23942396
{
23952397
PyArray_Descr *descr;
23962398

2399+
assert(arr != NULL);
23972400
if (arr == NULL) {
23982401
return;
23992402
}
@@ -2475,6 +2478,7 @@ UNICODE_copyswapn (char *dst, npy_intp dstride, char *src, npy_intp sstride,
24752478
{
24762479
int itemsize;
24772480

2481+
assert(arr != NULL);
24782482
if (arr == NULL) {
24792483
return;
24802484
}
@@ -2502,6 +2506,7 @@ UNICODE_copyswapn (char *dst, npy_intp dstride, char *src, npy_intp sstride,
25022506
static void
25032507
STRING_copyswap(char *dst, char *src, int NPY_UNUSED(swap), PyArrayObject *arr)
25042508
{
2509+
assert(arr != NULL);
25052510
if (arr == NULL) {
25062511
return;
25072512
}
@@ -2514,6 +2519,7 @@ UNICODE_copyswap (char *dst, char *src, int swap, PyArrayObject *arr)
25142519
{
25152520
int itemsize;
25162521

2522+
assert(arr != NULL);
25172523
if (arr == NULL) {
25182524
return;
25192525
}

0 commit comments

Comments
 (0)