Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

A suspicious use of an incrementer in for loop #33

Open
lifove opened this issue Jan 31, 2017 · 4 comments
Open

A suspicious use of an incrementer in for loop #33

lifove opened this issue Jan 31, 2017 · 4 comments

Comments

@lifove
Copy link

lifove commented Jan 31, 2017

Hi

I've found a suspicious use of an incrementer in the recent snapshot.
(Path: com.windowtester.swt.runtime/src/com/windowtester/runtime/swt/internal/finder/eclipse/views/ViewExplorer.java)

In Line 57, should views[i] be views[j]? I have no idea if categories.length is same as views.length so just report the issue.

Thanks!

53                 for (int i = 0; i < categories.length; i++) {
 54                         IViewCategory category = categories[i];
 55                         IViewDescriptor[] views = category.getViews();
 56                         for (int j = 0; j < views.length; j++) {
 57                                 IViewDescriptor candidateView = views[i];
 58                                 if (view == candidateView)
 59                                         return category.getLabel();
 60                         }
 61                 }
@fredg02
Copy link

fredg02 commented Feb 1, 2017

Indeed, this looks suspicious. How did you find that error? Just by accident? Have you tested the method where it is used?

@lifove
Copy link
Author

lifove commented Feb 1, 2017

I used a static analysis tool. Then, after reading the source code file, I found that it is quite suspicious as the loop was only one using inconsistent incrementers compared to that in other methods. I have not tested the method. Sorry for it.

@fredg02
Copy link

fredg02 commented Feb 2, 2017

No worries. Thanks for finding that issue.
Are you using WindowTester in production?

@lifove
Copy link
Author

lifove commented Feb 2, 2017

No, I'm just a researcher who wants to develop useful tools for developers. I was implementing my own static analysis tool that provides less (hopefully no) false positive results. Thanks!

fredg02 added a commit to fredg02/windowtester-1 that referenced this issue Feb 9, 2017
"A suspicious use of an incrementer in for loop"
fredg02 added a commit to fredg02/windowtester-1 that referenced this issue Feb 9, 2017
"A suspicious use of an incrementer in for loop"
fredg02 added a commit to fredg02/windowtester-1 that referenced this issue Feb 9, 2017
"A suspicious use of an incrementer in for loop"
fredg02 added a commit to fredg02/windowtester that referenced this issue Feb 9, 2017
"A suspicious use of an incrementer in for loop"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants