Skip to content
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

fix slice stackoverflow in certain scenarios #287

Closed
wants to merge 0 commits into from
Closed

fix slice stackoverflow in certain scenarios #287

wants to merge 0 commits into from

Conversation

hcanyz
Copy link

@hcanyz hcanyz commented May 12, 2023

fix #286

@google-cla
Copy link

google-cla bot commented May 12, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@devoncarew devoncarew requested a review from lrhn May 17, 2023 17:50
@devoncarew
Copy link
Member

@hcanyz - thanks for the contribution! Can you update the changelog and the pubspec version as per https://github.com/dart-lang/.github/blob/main/PULL_REQUEST_TEMPLATE.md?

Copy link
Member

@lrhn lrhn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix, thank you.

As @devoncarew said, upping the version in the SDK (just a minor version increment is enough) and adding an entry in CHANGELOG.md saying what that version does (fixes bug in List.slice and ListSlice.slice methods), should be enough to make it publishable.

@@ -241,7 +241,7 @@ extension ListExtensions<E> on List<E> {
ListSlice<E> slice(int start, [int? end]) {
end = RangeError.checkValidRange(start, end, length);
var self = this;
if (self is ListSlice) return self.slice(start, end);
if (self is ListSlice<E>) return self.slice(start, end);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is a constant foot-gun. I'll add another notch to the issue suggesting we promote to ListSlice<E> here.)

@@ -404,7 +404,7 @@ class ListSlice<E> extends ListBase<E> {
/// ```
ListSlice<E> slice(int start, [int? end]) {
end = RangeError.checkValidRange(start, end, length);
return ListSlice._(_initialSize, source, start + start, end - start);
return ListSlice._(_initialSize, source, this.start + start, end - start);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just bad. Sorry 😢

@devoncarew
Copy link
Member

@hcanyz - thanks for the follow-up; can you also update the pubspec version to 1.17.3 (to match the changelog entry)? Thanks!

CHANGELOG.md Outdated
@@ -1,3 +1,7 @@
## 1.17.3

* Fixes bug in List.slice and ListSlice.slice methods.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Fixes bug in List.slice and ListSlice.slice methods.
* Fixes a bug in the `List.slice` and `ListSlice.slice` methods.

@hcanyz hcanyz closed this May 20, 2023
@hcanyz
Copy link
Author

hcanyz commented May 20, 2023

1.18.0-wip has been committed on the master branch, and I don't know how to proceed with submitting this PR. Use 1.18.1 ?, or you guys come and commit this change : ) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slice method will Stack Overflow in certain scenarios
3 participants