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
02dd539d
Kaydet (Commit)
02dd539d
authored
Eyl 02, 2011
tarafından
Amaury Forgeot d'Arc
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #12764: Fix a crash in ctypes when the name of a Structure field is not
a string.
üst
172f374a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
test_structures.py
Lib/ctypes/test/test_structures.py
+8
-0
NEWS
Misc/NEWS
+3
-0
stgdict.c
Modules/_ctypes/stgdict.c
+15
-2
No files found.
Lib/ctypes/test/test_structures.py
Dosyayı görüntüle @
02dd539d
...
@@ -239,6 +239,14 @@ class StructureTestCase(unittest.TestCase):
...
@@ -239,6 +239,14 @@ class StructureTestCase(unittest.TestCase):
pass
pass
self
.
assertRaises
(
TypeError
,
setattr
,
POINT
,
"_fields_"
,
[(
"x"
,
1
),
(
"y"
,
2
)])
self
.
assertRaises
(
TypeError
,
setattr
,
POINT
,
"_fields_"
,
[(
"x"
,
1
),
(
"y"
,
2
)])
def
test_invalid_name
(
self
):
# field name must be string
def
declare_with_name
(
name
):
class
S
(
Structure
):
_fields_
=
[(
name
,
c_int
)]
self
.
assertRaises
(
TypeError
,
declare_with_name
,
b
"x"
)
def
test_intarray_fields
(
self
):
def
test_intarray_fields
(
self
):
class
SomeInts
(
Structure
):
class
SomeInts
(
Structure
):
_fields_
=
[(
"a"
,
c_int
*
4
)]
_fields_
=
[(
"a"
,
c_int
*
4
)]
...
...
Misc/NEWS
Dosyayı görüntüle @
02dd539d
...
@@ -193,6 +193,9 @@ Library
...
@@ -193,6 +193,9 @@ Library
Extension Modules
Extension Modules
-----------------
-----------------
- Issue #12764: Fix a crash in ctypes when the name of a Structure field is not
a string.
- Issue #11241: subclasses of ctypes.Array can now be subclassed.
- Issue #11241: subclasses of ctypes.Array can now be subclassed.
- Issue #9651: Fix a crash when ctypes.create_string_buffer(0) was passed to
- Issue #9651: Fix a crash when ctypes.create_string_buffer(0) was passed to
...
...
Modules/_ctypes/stgdict.c
Dosyayı görüntüle @
02dd539d
...
@@ -482,8 +482,21 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
...
@@ -482,8 +482,21 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
char
*
fieldfmt
=
dict
->
format
?
dict
->
format
:
"B"
;
char
*
fieldfmt
=
dict
->
format
?
dict
->
format
:
"B"
;
char
*
fieldname
=
_PyUnicode_AsString
(
name
);
char
*
fieldname
=
_PyUnicode_AsString
(
name
);
char
*
ptr
;
char
*
ptr
;
Py_ssize_t
len
=
strlen
(
fieldname
)
+
strlen
(
fieldfmt
);
Py_ssize_t
len
;
char
*
buf
=
alloca
(
len
+
2
+
1
);
char
*
buf
;
if
(
fieldname
==
NULL
)
{
PyErr_Format
(
PyExc_TypeError
,
"structure field name must be string not %s"
,
name
->
ob_type
->
tp_name
);
Py_DECREF
(
pair
);
return
-
1
;
}
len
=
strlen
(
fieldname
)
+
strlen
(
fieldfmt
);
buf
=
alloca
(
len
+
2
+
1
);
sprintf
(
buf
,
"%s:%s:"
,
fieldfmt
,
fieldname
);
sprintf
(
buf
,
"%s:%s:"
,
fieldfmt
,
fieldname
);
...
...
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