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
e89cc44d
Commit
e89cc44d
authored
5 years ago
by
gsamain
Committed by
Xavier Thompson
4 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect cypclass dereferencing with overloaded operators
parent
5fcfa5a1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+4
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
e89cc44d
...
@@ -11463,7 +11463,7 @@ class NumBinopNode(BinopNode):
...
@@ -11463,7 +11463,7 @@ class NumBinopNode(BinopNode):
else
:
else
:
result1
,
result2
=
self
.
operand1
.
result
(),
self
.
operand2
.
result
()
result1
,
result2
=
self
.
operand1
.
result
(),
self
.
operand2
.
result
()
if
self
.
operand1
.
type
.
is_cyp_class
:
if
self
.
operand1
.
type
.
is_cyp_class
:
result1
=
'*'
+
result1
result1
=
"(*%s)"
%
result1
return
"(%s %s %s)"
%
(
result1
,
self
.
operator
,
result2
)
return
"(%s %s %s)"
%
(
result1
,
self
.
operator
,
result2
)
else
:
else
:
func
=
self
.
type
.
binary_op
(
self
.
operator
)
func
=
self
.
type
.
binary_op
(
self
.
operator
)
...
@@ -11890,7 +11890,7 @@ class ModNode(DivNode):
...
@@ -11890,7 +11890,7 @@ class ModNode(DivNode):
else
:
else
:
op1
=
self
.
operand1
.
result
()
op1
=
self
.
operand1
.
result
()
if
self
.
operand1
.
type
.
is_cyp_class
:
if
self
.
operand1
.
type
.
is_cyp_class
:
op1
=
'*'
+
op1
op1
=
"(*%s)"
%
op1
return
"(%s %% %s)"
%
(
return
"(%s %% %s)"
%
(
op1
,
op1
,
self
.
operand2
.
result
())
self
.
operand2
.
result
())
...
@@ -11961,7 +11961,7 @@ class PowNode(NumBinopNode):
...
@@ -11961,7 +11961,7 @@ class PowNode(NumBinopNode):
return
self
.
type
.
cast_code
(
operand
.
result
())
return
self
.
type
.
cast_code
(
operand
.
result
())
op1
=
typecast
(
self
.
operand1
)
op1
=
typecast
(
self
.
operand1
)
if
self
.
operand1
.
type
.
is_cyp_class
:
if
self
.
operand1
.
type
.
is_cyp_class
:
op1
=
'*'
+
op1
op1
=
"(*%s)"
%
op1
return
"%s(%s, %s)"
%
(
return
"%s(%s, %s)"
%
(
self
.
pow_func
,
self
.
pow_func
,
op1
,
op1
,
...
@@ -12921,7 +12921,7 @@ class PrimaryCmpNode(ExprNode, CmpNode):
...
@@ -12921,7 +12921,7 @@ class PrimaryCmpNode(ExprNode, CmpNode):
else
:
else
:
result1
,
result2
=
operand1
.
result
(),
operand2
.
result
()
result1
,
result2
=
operand1
.
result
(),
operand2
.
result
()
if
operand1
.
type
.
is_cyp_class
and
self
.
operator
not
in
(
"is"
,
"is_not"
):
if
operand1
.
type
.
is_cyp_class
and
self
.
operator
not
in
(
"is"
,
"is_not"
):
result1
=
'*'
+
result1
result1
=
"(*%s)"
%
result1
if
self
.
is_memslice_nonecheck
:
if
self
.
is_memslice_nonecheck
:
if
operand1
.
type
.
is_memoryviewslice
:
if
operand1
.
type
.
is_memoryviewslice
:
result1
=
"((PyObject *) %s.memview)"
%
result1
result1
=
"((PyObject *) %s.memview)"
%
result1
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/Nodes.py
View file @
e89cc44d
...
@@ -6127,7 +6127,7 @@ class InPlaceAssignmentNode(AssignmentNode):
...
@@ -6127,7 +6127,7 @@ class InPlaceAssignmentNode(AssignmentNode):
# TODO: make sure overload is declared
# TODO: make sure overload is declared
l_op
=
lhs
.
result
()
l_op
=
lhs
.
result
()
if
lhs
.
type
.
is_cyp_class
:
if
lhs
.
type
.
is_cyp_class
:
l_op
=
'*'
+
l_op
l_op
=
"(*%s)"
%
l_op
code
.
putln
(
"%s %s= %s;"
%
(
l_op
,
c_op
,
rhs
.
result
()))
code
.
putln
(
"%s %s= %s;"
%
(
l_op
,
c_op
,
rhs
.
result
()))
lhs
.
generate_subexpr_disposal_code
(
code
)
lhs
.
generate_subexpr_disposal_code
(
code
)
lhs
.
free_subexpr_temps
(
code
)
lhs
.
free_subexpr_temps
(
code
)
...
...
This diff is collapsed.
Click to expand it.
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