Skip to content

Bound Tribonacci allocations for malformed lengths - #106

Closed
krotname wants to merge 1 commit into
mainfrom
codex/fix-input-validation-in-tribonacci-method
Closed

Bound Tribonacci allocations for malformed lengths#106
krotname wants to merge 1 commit into
mainfrom
codex/fix-input-validation-in-tribonacci-method

Conversation

@krotname

@krotname krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Harden the TribonacciSequence.tribonacci implementation to reject negative or excessively large n before allocating the result array, preventing crashes (NegativeArraySizeException/ArrayIndexOutOfBoundsException) and OutOfMemoryError for malformed inputs.

Description

  • Add MAX_SEQUENCE_LENGTH = 1_000_000 and validate n (0 <= n <= MAX_SEQUENCE_LENGTH) in src/main/java/kyu6/TribonacciSequence.java, and add a regression case in src/test/java/kyu6/TribonacciSequenceTest.java that asserts Integer.MAX_VALUE is rejected without allocation.

Testing

  • Ran mvn -q -Dtest=kyu6.TribonacciSequenceTest test and mvn -q test, and ran mvn -q -DskipTests checkstyle:check, all of which completed successfully.

Codex Task

@krotname

krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the validated combined merge in #115: #115

@krotname krotname closed this Aug 1, 2026
@krotname
krotname deleted the codex/fix-input-validation-in-tribonacci-method branch August 1, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant