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
32a7df2a
Commit
32a7df2a
authored
Sep 12, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid potentially unsafe downcast
parent
71902f2b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+3
-7
No files found.
Cython/Utility/StringTools.c
View file @
32a7df2a
...
...
@@ -395,23 +395,19 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
//@requires: IncludeStringH
/* duplicate code to avoid calling strlen() if start >= 0 and stop >= 0 */
/* Casting to Py_ssize_t and checking for negative values to determine
* if overflow occured should be safe in practice (it's undefined
* behavior by C99, but common behavior for systems with
* two-complement representation).
*/
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_c_string
(
const
char
*
cstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
))
{
Py_ssize_t
length
;
if
(
unlikely
((
start
<
0
)
|
(
stop
<
0
)))
{
length
=
(
Py_ssize_t
)
strlen
(
cstring
);
if
(
length
<
0
)
{
size_t
slen
=
strlen
(
cstring
);
if
(
unlikely
(
slen
>
(
size_t
)
PY_SSIZE_T_MAX
)
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"c-string too long to convert to Python"
);
return
NULL
;
}
length
=
(
Py_ssize_t
)
slen
;
if
(
start
<
0
)
{
start
+=
length
;
if
(
start
<
0
)
...
...
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