AMashenkov commented on code in PR #5479: URL: https://github.com/apache/ignite-3/pull/5479#discussion_r2026563030
########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/SortNode.java: ########## @@ -59,18 +58,19 @@ public class SortNode<RowT> extends AbstractNode<RowT> implements SingleNode<Row */ public SortNode(ExecutionContext<RowT> ctx, Comparator<RowT> comp, - @Nullable Supplier<Integer> offset, - @Nullable Supplier<Integer> fetch) { + long offset, + long fetch) { super(ctx); - assert fetch == null || fetch.get() >= 0; - assert offset == null || offset.get() >= 0; - limit = fetch == null ? -1 : fetch.get() + (offset == null ? 0 : offset.get()); + assert fetch == -1 || fetch >= 0; + assert offset >= 0; - if (limit < 1) { + limit = fetch == -1 ? -1 : IgniteMath.addExact(fetch, offset); + + if (limit < 1 || limit > Integer.MAX_VALUE) { Review Comment: Both queue implementation are backed by arrays. So, limit greater `Integer.MAX_VALUE` may lead to a int overflow and array out bounds. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org