Skip to content

Avoid integer underflow and wasted iterations in ToPagedEnumerable. - #13

Closed
extraes wants to merge 5 commits into
nickelc:masterfrom
extraes:master
Closed

extraes wants to merge 5 commits into
nickelc:masterfrom
extraes:master

Conversation

@extraes

@extraes extraes commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

SearchClient.ToPagedEnumerable can underflow remaining if result.Total and result.Count are different (particularly, if count is greater than total), leading to the paginator asking for a bunch of empty pages at absurd offsets.

This has actually happened, as a heap dump from a running bot confirmed that the remaining variable was 0xFFFFFFFE (4,294,967,294 in decimal, or 0 - 2 in math).

And to avoid wasting iterations on empty responses, in case someone intentionally puts a huge offset in, just yield break when receiving an empty count.

@nickelc

nickelc commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Thank you for the changes.

I pushed them as bb293a5 and dfcf196.

@nickelc nickelc closed this Sep 17, 2026
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.

2 participants