RFR: 8346785: Potential infinite loop in JavadocTokenizer.ensures
Chen Liang
liach at openjdk.org
Mon Apr 14 19:13:43 UTC 2025
On Mon, 14 Apr 2025 10:59:48 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:
> Please review this patch to fix a potential infinite loop in `JavadocTokenizer.ensure` when `map.length` and `size + need` approach Interger.MAX_VALUE.
>
> While I couldn't reproduce the issue even with large inputs (~1.9GB java file where almost the entire file is one javadoc comment), the fix is about correctness and prevention of UB in extreme cases.
>
> TIA
Consider if `grow == 0`, the while loop still stalls infinitely. I think the best solution is, after `grow <<= 1;`, add a check in the loop like `if (grow <= 0) throw new IndexOutOfBoundsException();` and keeping everything else as-is.
-------------
Changes requested by liach (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/24620#pullrequestreview-2765418753
More information about the javadoc-dev
mailing list