/** * looks for stores to registers, if that store is an array, builds a wrapper info for it and stores it in the wrappers collection. If it is a regular * store, sees if this value, came from a wrapper array passed into a method, and if so reports it. * * @param seen * the currently parsed opcode */ private void processLocalStore(int seen) { if (stack.getStackDepth() == 0) { return; } OpcodeStack.Item itm = stack.getStackItem(0); String sig = itm.getSignature(); if (sig.startsWith(Values.SIG_ARRAY_PREFIX)) { int reg = RegisterUtils.getAStoreReg(this, seen); Integer elReg = (Integer) itm.getUserValue(); if (elReg != null) { wrappers.put(Integer.valueOf(reg), new WrapperInfo(elReg.intValue())); } } else { Integer elReg = (Integer) itm.getUserValue(); if ((elReg != null) && (elReg.intValue() == RegisterUtils.getAStoreReg(this, seen))) { bugReporter.reportBug(new BugInstance(this, BugType.AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addSourceLine(this)); } } }
/** * looks for stores to registers, if that store is an array, builds a wrapper info for it and stores it in the wrappers collection. If it is a regular * store, sees if this value, came from a wrapper array passed into a method, and if so reports it. * * @param seen * the currently parsed opcode */ private void processLocalStore(int seen) { if (stack.getStackDepth() == 0) { return; } OpcodeStack.Item itm = stack.getStackItem(0); String sig = itm.getSignature(); if (sig.startsWith(Values.SIG_ARRAY_PREFIX)) { int reg = RegisterUtils.getAStoreReg(this, seen); Integer elReg = (Integer) itm.getUserValue(); if (elReg != null) { wrappers.put(Integer.valueOf(reg), new WrapperInfo(elReg.intValue())); } } else { Integer elReg = (Integer) itm.getUserValue(); if ((elReg != null) && (elReg.intValue() == RegisterUtils.getAStoreReg(this, seen))) { bugReporter.reportBug(new BugInstance(this, BugType.AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addSourceLine(this)); } } }