Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7213fcc2
Kaydet (Commit)
7213fcc2
authored
Şub 01, 2015
tarafından
Stefan Krah
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23370: Fix off-by-one error for non-contiguous buffers.
üst
f046dfe6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
2 deletions
+53
-2
_testcapimodule.c
Modules/_testcapimodule.c
+51
-0
abstract.c
Objects/abstract.c
+2
-2
No files found.
Modules/_testcapimodule.c
Dosyayı görüntüle @
7213fcc2
...
@@ -2467,6 +2467,56 @@ make_memoryview_from_NULL_pointer(PyObject *self)
...
@@ -2467,6 +2467,56 @@ make_memoryview_from_NULL_pointer(PyObject *self)
return
NULL
;
return
NULL
;
return
PyMemoryView_FromBuffer
(
&
info
);
return
PyMemoryView_FromBuffer
(
&
info
);
}
}
static
PyObject
*
test_from_contiguous
(
PyObject
*
self
,
PyObject
*
noargs
)
{
int
data
[
9
]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
};
int
init
[
5
]
=
{
0
,
1
,
2
,
3
,
4
};
Py_ssize_t
itemsize
=
sizeof
(
int
);
Py_ssize_t
shape
=
5
;
Py_ssize_t
strides
=
2
*
itemsize
;
Py_buffer
view
=
{
data
,
NULL
,
5
*
itemsize
,
itemsize
,
1
,
1
,
NULL
,
&
shape
,
&
strides
,
NULL
,
NULL
};
int
*
ptr
;
int
i
;
PyBuffer_FromContiguous
(
&
view
,
init
,
view
.
len
,
'C'
);
ptr
=
view
.
buf
;
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
ptr
[
2
*
i
]
!=
i
)
{
PyErr_SetString
(
TestError
,
"test_from_contiguous: incorrect result"
);
return
NULL
;
}
}
view
.
buf
=
&
data
[
8
];
view
.
strides
[
0
]
=
-
2
*
itemsize
;
PyBuffer_FromContiguous
(
&
view
,
init
,
view
.
len
,
'C'
);
ptr
=
view
.
buf
;
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
*
(
ptr
-
2
*
i
)
!=
i
)
{
PyErr_SetString
(
TestError
,
"test_from_contiguous: incorrect result"
);
return
NULL
;
}
}
Py_RETURN_NONE
;
}
/* Test that the fatal error from not having a current thread doesn't
/* Test that the fatal error from not having a current thread doesn't
cause an infinite loop. Run via Lib/test/test_capi.py */
cause an infinite loop. Run via Lib/test/test_capi.py */
...
@@ -3031,6 +3081,7 @@ static PyMethodDef TestMethods[] = {
...
@@ -3031,6 +3081,7 @@ static PyMethodDef TestMethods[] = {
{
"test_string_to_double"
,
(
PyCFunction
)
test_string_to_double
,
METH_NOARGS
},
{
"test_string_to_double"
,
(
PyCFunction
)
test_string_to_double
,
METH_NOARGS
},
{
"test_unicode_compare_with_ascii"
,
(
PyCFunction
)
test_unicode_compare_with_ascii
,
METH_NOARGS
},
{
"test_unicode_compare_with_ascii"
,
(
PyCFunction
)
test_unicode_compare_with_ascii
,
METH_NOARGS
},
{
"test_capsule"
,
(
PyCFunction
)
test_capsule
,
METH_NOARGS
},
{
"test_capsule"
,
(
PyCFunction
)
test_capsule
,
METH_NOARGS
},
{
"test_from_contiguous"
,
(
PyCFunction
)
test_from_contiguous
,
METH_NOARGS
},
{
"getargs_tuple"
,
getargs_tuple
,
METH_VARARGS
},
{
"getargs_tuple"
,
getargs_tuple
,
METH_VARARGS
},
{
"getargs_keywords"
,
(
PyCFunction
)
getargs_keywords
,
{
"getargs_keywords"
,
(
PyCFunction
)
getargs_keywords
,
METH_VARARGS
|
METH_KEYWORDS
},
METH_VARARGS
|
METH_KEYWORDS
},
...
...
Objects/abstract.c
Dosyayı görüntüle @
7213fcc2
...
@@ -488,7 +488,7 @@ PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort)
...
@@ -488,7 +488,7 @@ PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort)
/* Otherwise a more elaborate scheme is needed */
/* Otherwise a more elaborate scheme is needed */
/*
XXX(nnorwitz): need to check for overflow!
*/
/*
view->ndim <= 64
*/
indices
=
(
Py_ssize_t
*
)
PyMem_Malloc
(
sizeof
(
Py_ssize_t
)
*
(
view
->
ndim
));
indices
=
(
Py_ssize_t
*
)
PyMem_Malloc
(
sizeof
(
Py_ssize_t
)
*
(
view
->
ndim
));
if
(
indices
==
NULL
)
{
if
(
indices
==
NULL
)
{
PyErr_NoMemory
();
PyErr_NoMemory
();
...
@@ -510,10 +510,10 @@ PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort)
...
@@ -510,10 +510,10 @@ PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort)
*/
*/
elements
=
len
/
view
->
itemsize
;
elements
=
len
/
view
->
itemsize
;
while
(
elements
--
)
{
while
(
elements
--
)
{
addone
(
view
->
ndim
,
indices
,
view
->
shape
);
ptr
=
PyBuffer_GetPointer
(
view
,
indices
);
ptr
=
PyBuffer_GetPointer
(
view
,
indices
);
memcpy
(
ptr
,
src
,
view
->
itemsize
);
memcpy
(
ptr
,
src
,
view
->
itemsize
);
src
+=
view
->
itemsize
;
src
+=
view
->
itemsize
;
addone
(
view
->
ndim
,
indices
,
view
->
shape
);
}
}
PyMem_Free
(
indices
);
PyMem_Free
(
indices
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment