Commit e89cc44d authored by gsamain's avatar gsamain Committed by Xavier Thompson

Protect cypclass dereferencing with overloaded operators

parent 5fcfa5a1
...@@ -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
......
...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment