-
Notifications
You must be signed in to change notification settings - Fork 332
Fix ISXB-1792: HaveDuplicateReferences inner loop bound (n < count no… #2376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,7 +120,7 @@ public static bool HaveDuplicateReferences<TFirst>(this TFirst[] first, int inde | |
| for (var i = 0; i < count; ++i) | ||
| { | ||
| var element = first[i]; | ||
| for (var n = i + 1; n < count - i; ++n) | ||
| for (var n = i + 1; n < count; ++n) | ||
|
Comment on lines
120
to
+123
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Should this be updated to respect the for (var i = index; i < index + count; ++i)
{
var element = first[i];
for (var n = i + 1; n < index + count; ++n)
{
if (ReferenceEquals(element, first[n]))
return true;
}
}🤖 Helpful? 👍/👎 |
||
| { | ||
| if (ReferenceEquals(element, first[n])) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🤖 Helpful? 👍/👎 |
||
| return true; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered adding a test case with a non-zero starting index (e.g.,
index: 1)? This would ensure the bounds are correctly respected. Because the implementation ofHaveDuplicateReferencescurrently ignores theindexparameter, a test relying on an offset would fail, helping to expose the missing offset bug.🤖 Helpful? 👍/👎