High: Null safety bugs and fragile puzzle generation #28

Closed
opened 2026-06-10 15:16:01 +00:00 by Mark · 0 comments
Owner

Findings

  • H4: WordSearchActivity — grid array accessed in generatePuzzle() before it's initialized when chapter is null. NPE path.
  • H5: WordSearch puzzle only attempts 50 random placements per word. Long words (6+) in small grids (6×6) have very low fit probability — silently produces puzzles with missing words.
  • M4: MazeActivity — default mazeSize=8 initialized at construction, but loadConfig() may reassign it. Works by accident when config returns null because both paths land on 8.
  • M6: Jigsaw piece count allows non-perfect-square values (5-7, 10-15). sqrt(pieceCount).toInt() for column count is incorrect — cell count won't match grid, causing layout glitches or index crashes.

Affected files

  • android/app/src/main/java/com/storyplay/activitybook/ui/WordSearchActivity.kt
  • android/app/src/main/java/com/storyplay/activitybook/ui/MazeActivity.kt
  • android/app/src/main/java/com/storyplay/activitybook/ui/JigsawActivity.kt

Impact

NullPointerExceptions and broken puzzles at runtime.

## Findings - **H4**: WordSearchActivity — `grid` array accessed in `generatePuzzle()` before it's initialized when `chapter` is null. NPE path. - **H5**: WordSearch puzzle only attempts 50 random placements per word. Long words (6+) in small grids (6×6) have very low fit probability — silently produces puzzles with missing words. - **M4**: MazeActivity — default `mazeSize=8` initialized at construction, but `loadConfig()` may reassign it. Works by accident when config returns null because both paths land on 8. - **M6**: Jigsaw piece count allows non-perfect-square values (5-7, 10-15). `sqrt(pieceCount).toInt()` for column count is incorrect — cell count won't match grid, causing layout glitches or index crashes. ## Affected files - `android/app/src/main/java/com/storyplay/activitybook/ui/WordSearchActivity.kt` - `android/app/src/main/java/com/storyplay/activitybook/ui/MazeActivity.kt` - `android/app/src/main/java/com/storyplay/activitybook/ui/JigsawActivity.kt` ## Impact NullPointerExceptions and broken puzzles at runtime.
Sign in to join this conversation.
No description provided.