8000 [3.13] gh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM… · python/cpython@afef6b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit afef6b5

Browse files
[3.13] gh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM() (GH-120228) (#120238)
gh-120155: Fix copy/paste error in HAVE_SUBOFFSETS_IN_LAST_DIM() (GH-120228) Don't hardcode 'dest' in HAVE_SUBOFFSETS_IN_LAST_DIM() macro of memoryobject.c, but use its 'view' parameter instead. Fix the Coverity issue: Error: COPY_PASTE_ERROR (CWE-398): Python-3.12.2/Objects/memoryobject.c:273:14: original: ""dest->suboffsets + (dest->ndim - 1)"" looks like the original copy. Python-3.12.2/Objects/memoryobject.c:274:14: copy_paste_error: ""dest"" in ""src->suboffsets + (dest->ndim - 1)"" looks like a copy-paste error. Python-3.12.2/Objects/memoryobject.c:274:14: remediation: Should it say ""src"" instead? GH- 272| assert(dest->ndim > 0 && src->ndim > 0); GH- 273| return (!HAVE_SUBOFFSETS_IN_LAST_DIM(dest) && GH- 274|-> !HAVE_SUBOFFSETS_IN_LAST_DIM(src) && GH- 275| dest->strides[dest->ndim-1] == dest->itemsize && GH- 276| src->strides[src->ndim-1] == src->itemsize); (cherry picked from commit 90b7540) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 18359f2 commit afef6b5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Objects/memoryobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ PyTypeObject _PyManagedBuffer_Type = {
268268
/* Assumptions: ndim >= 1. The macro tests for a corner case that should
269269
perhaps be explicitly forbidden in the PEP. */
270270
#define HAVE_SUBOFFSETS_IN_LAST_DIM(view) \
271-
(view->suboffsets && view->suboffsets[dest->ndim-1] >= 0)
271+
(view->suboffsets && view->suboffsets[view->ndim-1] >= 0)
272272

273273
static inline int
274274
last_dim_is_contiguous(const Py_buffer *dest, const Py_buffer *src)

0 commit comments

Comments
 (0)
0