A suspicious use of incrementer in for loop
- Dominant language
- Java
- Stars
- 287
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
Hi
I've found a suspicious use of incrementer in for loop in recent snapshot.
(Path: java/sage/PseudoMenu.java)
In Line 360, listenKids[i] should be listenKids[j]? I have no idea if listenKids.length is always 3 as i is < 3.
```java
335 for (int i = 0; i < 3; i++)
336 {
337 Widget ueListenWidg = null;
338 if (i == 0)
339 ueListenWidg = getUEListenWidget(evt.getType());
340 else if (i == 1 && evt.getSecondaryType() != 0)
341 ueListenWidg = getUEListenWidget(evt.getSecondaryType());
342 else if (i == 2 && evt.getTernaryType() != 0)
343 ueListenWidg = getUEListenWidget(evt.getTernaryType());
344
345 if (ueListenWidg != null)
346 {
347 // 11/11/03 - I used to not create a child context here, but I added it when I did the
348 // passive listen stuff
349 Widget[] listenKids = ueListenWidg.contents();
350 Catbert.Context childContext = comp.relatedContext.createChild();
351 childContext.setLocal(Catbert.PASSIVE_LISTEN_VAR, null);
352 if (evt.getPayloads() != null)
353 childContext.setLocal(ZPseudoComp.PAYLOAD_VAR, evt.getPayloads());
354 for (int j = 0; j < listenKids.length; j++)
355 {
356 if (listenKids[j].isProcessChainType())
357 {
358 if ((ep = ZPseudoComp.processChain(listenKids[j], childContext, null, comp, false)) != null)
359 {
360 ep.addToStack(listenKids[i]);
361 ep.addToStackFinal(ueListenWidg);
362 return;
363 }
364 }
365 }
```
Contributor guide
Research direction
Start in java/sage/PseudoMenu.java around lines 354-361 and trace how listenKids is used when processing a process-chain widget. Verify whether the stack should receive the child at index j rather than the outer loop's i, and confirm the fix against the surrounding event-processing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100