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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2d3912ac
Commit
2d3912ac
authored
Aug 29, 2018
by
cjgibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect against values for self.start and self.stop that are non-trivial.
parent
1a83f191
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+11
-8
No files found.
Cython/Compiler/ExprNodes.py
View file @
2d3912ac
...
...
@@ -4748,12 +4748,12 @@ class SliceIndexNode(ExprNode):
env
,
getting
=
getting
,
setting
=
not
getting
,
analyse_base
=
False
)
from
.UtilNodes
import
ResultRefNode
from
.UtilNodes
import
EvalWithTempExprNode
,
ResultRefNode
if
self
.
start
:
self
.
start
.
analyse_types
(
env
)
if
self
.
start
.
type
.
is_pyobject
:
start_ref
=
ResultRefNode
(
self
.
start
)
s
elf
.
start
=
CondExprNode
(
s
tart_expr
=
CondExprNode
(
self
.
start
.
pos
,
true_val
=
IntNode
(
self
.
start
.
pos
,
...
...
@@ -4768,19 +4768,21 @@ class SliceIndexNode(ExprNode):
operand2
=
NoneNode
(
self
.
start
.
pos
),
)
)
self
.
start
.
coerce_to
(
PyrexTypes
.
c_py_ssize_t_type
,
env
)
self
.
start
.
analyse_types
(
env
)
start_expr
.
coerce_to
(
PyrexTypes
.
c_py_ssize_t_type
,
env
)
start_expr
.
analyse_types
(
env
)
self
.
start
=
EvalWithTempExprNode
(
start_ref
,
start_expr
)
if
self
.
stop
:
self
.
stop
.
analyse_types
(
env
)
if
self
.
stop
.
type
.
is_pyobject
:
stop_ref
=
ResultRefNode
(
self
.
stop
)
s
elf
.
stop
=
CondExprNode
(
s
top_expr
=
CondExprNode
(
self
.
stop
.
pos
,
true_val
=
IntNode
(
self
.
stop
.
pos
,
value
=
'PY_SSIZE_T_MAX'
,
# See: github.com/python/cpython/blob/2.7/Python/sysmodule.c#L1446
constant_result
=
sys
.
maxsize
constant_result
=
sys
.
maxsize
,
type
=
PyrexTypes
.
c_py_ssize_t_type
),
false_val
=
stop_ref
,
test
=
PrimaryCmpNode
(
...
...
@@ -4790,8 +4792,9 @@ class SliceIndexNode(ExprNode):
operand2
=
NoneNode
(
self
.
stop
.
pos
),
)
)
self
.
stop
.
coerce_to
(
PyrexTypes
.
c_py_ssize_t_type
,
env
)
self
.
stop
.
analyse_types
(
env
)
stop_expr
.
coerce_to
(
PyrexTypes
.
c_py_ssize_t_type
,
env
)
stop_expr
.
analyse_types
(
env
)
self
.
stop
=
EvalWithTempExprNode
(
stop_ref
,
stop_expr
)
if
not
env
.
directives
[
'wraparound'
]:
check_negative_indices
(
self
.
start
,
self
.
stop
)
...
...
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