Skip to content

Commit a65e6c0

Browse files
committed
fix comment and add null check
1 parent 42dc2f0 commit a65e6c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/instrumentation/CapturedContextInstrumentor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ private void rewriteLocalVarInsn(LocalVariableNode localVar, int oldSlot, int ne
640640
// 10: astore_1
641641
// 11: aload_1
642642
// range for slot 1 starts at 11
643-
// javac always starts the range right after the init of the local var, so we can just look for
644-
// the previous instruction
643+
// javac often starts the range right after the init of the local var, so we can just look for
644+
// the previous instruction. But not always, and we put an arbitrary limit to 10 instructions
645645
// for kotlinc, many instructions can separate the init and the range start
646646
// ex:
647647
// LocalVariableTable:
@@ -659,7 +659,7 @@ private static void rewritePreviousStoreInsn(
659659
AbstractInsnNode previous = localVar.start.getPrevious();
660660
int processed = 0;
661661
// arbitrary fixing limit to 10 previous instructions to look at
662-
while (!isVarStoreForSlot(previous, oldSlot) && processed < 10) {
662+
while (previous != null && !isVarStoreForSlot(previous, oldSlot) && processed < 10) {
663663
previous = previous.getPrevious();
664664
processed++;
665665
}

0 commit comments

Comments
 (0)