Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
58d9361e
Commit
58d9361e
authored
Feb 22, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix buffer format validation for sequences of strings in structs
parent
13b89088
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
11 deletions
+35
-11
CHANGES.rst
CHANGES.rst
+2
-0
Cython/Utility/Buffer.c
Cython/Utility/Buffer.c
+17
-11
tests/buffers/buffmt.pyx
tests/buffers/buffmt.pyx
+16
-0
No files found.
CHANGES.rst
View file @
58d9361e
...
...
@@ -18,6 +18,8 @@ Bugs fixed
* C++ destructor calls in extension types could fail to compile in clang.
* Buffer format validation failed for sequences of strings in structs.
* Docstrings on extension type attributes in .pxd files were rejected.
...
...
Cython/Utility/Buffer.c
View file @
58d9361e
...
...
@@ -638,8 +638,8 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
int
got_Z
=
0
;
while
(
1
)
{
/* puts(ts); */
switch
(
*
ts
)
{
/* puts(ts); */
case
0
:
if
(
ctx
->
enc_type
!=
0
&&
ctx
->
head
==
NULL
)
{
__Pyx_BufFmt_RaiseExpected
(
ctx
);
...
...
@@ -650,7 +650,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
__Pyx_BufFmt_RaiseExpected
(
ctx
);
return
NULL
;
}
return
ts
;
return
ts
;
case
' '
:
case
'\r'
:
case
'\n'
:
...
...
@@ -730,23 +730,29 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
if
(
*
ts
!=
'f'
&&
*
ts
!=
'd'
&&
*
ts
!=
'g'
)
{
__Pyx_BufFmt_RaiseUnexpectedChar
(
'Z'
);
return
NULL
;
}
/* fall through */
}
/* fall through */
case
'c'
:
case
'b'
:
case
'B'
:
case
'h'
:
case
'H'
:
case
'i'
:
case
'I'
:
case
'l'
:
case
'L'
:
case
'q'
:
case
'Q'
:
case
'f'
:
case
'd'
:
case
'g'
:
case
'O'
:
case
'
s'
:
case
'
p'
:
case
'O'
:
case
'p'
:
if
(
ctx
->
enc_type
==
*
ts
&&
got_Z
==
ctx
->
is_complex
&&
ctx
->
enc_packmode
==
ctx
->
new_packmode
)
{
/* Continue pooling same type */
ctx
->
enc_count
+=
ctx
->
new_count
;
}
else
{
/* New type */
if
(
__Pyx_BufFmt_ProcessTypeChunk
(
ctx
)
==
-
1
)
return
NULL
;
ctx
->
enc_count
=
ctx
->
new_count
;
ctx
->
enc_packmode
=
ctx
->
new_packmode
;
ctx
->
enc_type
=
*
ts
;
ctx
->
is_complex
=
got_Z
;
ctx
->
new_count
=
1
;
got_Z
=
0
;
++
ts
;
break
;
}
/* fall through */
case
's'
:
/* 's' or new type (cannot be added to current pool) */
if
(
__Pyx_BufFmt_ProcessTypeChunk
(
ctx
)
==
-
1
)
return
NULL
;
ctx
->
enc_count
=
ctx
->
new_count
;
ctx
->
enc_packmode
=
ctx
->
new_packmode
;
ctx
->
enc_type
=
*
ts
;
ctx
->
is_complex
=
got_Z
;
++
ts
;
ctx
->
new_count
=
1
;
got_Z
=
0
;
...
...
tests/buffers/buffmt.pyx
View file @
58d9361e
...
...
@@ -377,6 +377,22 @@ def partially_packed_struct_2(fmt):
fmt
,
sizeof
(
PartiallyPackedStruct2
))
cdef
packed
struct
PackedStructWithCharArrays
:
float
a
int
b
char
[
5
]
c
char
[
3
]
d
@
testcase
def
packed_struct_with_strings
(
fmt
):
"""
>>> packed_struct_with_strings("T{f:a:i:b:5s:c:3s:d:}")
"""
cdef
object
[
PackedStructWithCharArrays
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
PackedStructWithCharArrays
))
# TODO: empty struct
# TODO: Incomplete structs
# TODO: mixed structs
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