From: Matthieu Volat Date: Thu, 12 Jan 2017 16:18:24 +0000 (+0100) Subject: Sanitize the rest of dwarf operation regarding stack popping. X-Git-Tag: v3_15~555 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ae8bc2f85984970c4ef47e6adbdff67c423ba034 Sanitize the rest of dwarf operation regarding stack popping. In all those cases, the order of pop() was not an issue since the operations were commutatives, but those could give bad ideas for other cases. --- diff --git a/src/mc/DwarfExpression.cpp b/src/mc/DwarfExpression.cpp index 03298eb6ba..86043a0bf9 100644 --- a/src/mc/DwarfExpression.cpp +++ b/src/mc/DwarfExpression.cpp @@ -205,13 +205,19 @@ void execute( // and replace the top of the stack with the computed value // (stack.top() += stack.before_top()). - case DW_OP_plus: - stack.push(stack.pop() + stack.pop()); + case DW_OP_plus: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first + second); break; + } - case DW_OP_mul: - stack.push(stack.pop() * stack.pop()); + case DW_OP_mul: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first * second); break; + } case DW_OP_plus_uconst: stack.top() += op->number; @@ -232,17 +238,26 @@ void execute( break; } - case DW_OP_and: - stack.push(stack.pop() & stack.pop()); + case DW_OP_and: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first & second); break; + } - case DW_OP_or: - stack.push(stack.pop() | stack.pop()); + case DW_OP_or: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first | second); break; + } - case DW_OP_xor: - stack.push(stack.pop() ^ stack.pop()); + case DW_OP_xor: { + intptr_t first = stack.pop(); + intptr_t second = stack.pop(); + stack.push(first ^ second); break; + } case DW_OP_nop: break;