From 971e65272dc252d1e26b0f336100e6b5fdbd0a0d Mon Sep 17 00:00:00 2001 From: cgewecke Date: Fri, 9 Dec 2016 09:56:18 -0800 Subject: [PATCH] Fix injection issue with else statements without brackets --- instrumentSolidity.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instrumentSolidity.js b/instrumentSolidity.js index 506edb7..c38baba 100644 --- a/instrumentSolidity.js +++ b/instrumentSolidity.js @@ -158,8 +158,10 @@ module.exports = function(contract, fileName, instrumentingActive){ createOrAppendInjectionPoint(expression.alternate.start, {type: "callBranchEvent", branchId: branchId, locationIdx:1, openBracket: true}) createOrAppendInjectionPoint(expression.alternate.end, {type:"closeBracketEnd"}); //It should get instrumented when we parse it - } else if (expression.alternate){ + } else if (expression.alternate && contract.slice(expression.alternate.start,expression.alternate.end).trim().indexOf('{')===0){ createOrAppendInjectionPoint(expression.alternate.start+1, {type: "callBranchEvent", branchId: branchId, locationIdx: 1}) + } else if (expression.alternate){ + createOrAppendInjectionPoint(expression.alternate.start, {type: "callBranchEvent", branchId: branchId, locationIdx: 1}) } else { createOrAppendInjectionPoint(expression.consequent.end, {type: "callEmptyBranchEvent", branchId: branchId, locationIdx: 1}); }