Skip to content

Fix ArrayIndexOutOfBoundsException in createTempFileSecure - #257

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
arrayindexoutofboundsexception-length3-index3-6azngf
Draft

Fix ArrayIndexOutOfBoundsException in createTempFileSecure#257
cursor[bot] wants to merge 1 commit into
mainfrom
arrayindexoutofboundsexception-length3-index3-6azngf

Conversation

@cursor

@cursor cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Fixed an off-by-one error in MyBaseActivity.createTempFileSecure that caused an ArrayIndexOutOfBoundsException when the random index generator produced a value equal to the array length.

Changes

  • Changed boundary check from index > cacheFiles.length to index >= cacheFiles.length on line 163
  • This prevents accessing the array at an index equal to its length, which is out of bounds

Root Cause

The condition index > cacheFiles.length allowed index to equal cacheFiles.length, which is invalid for array access. Arrays are zero-indexed with valid range 0..length-1, so index == length is out of bounds and causes an exception when accessing cacheFiles[index].

Fixes ANDROID-JG

Open in Web Open in Cursor 

Change boundary check from 'index > cacheFiles.length' to 'index >= cacheFiles.length' to prevent accessing array at index equal to length. Arrays are zero-indexed (valid range 0..length-1), so index == length is out of bounds.

Fixes [ANDROID-JG](https://demo.sentry.io/issues/7601217253/)
@sentry

sentry Bot commented Aug 16, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Android com.example.vu.android 24.12.26 (241226) release
Android com.example.vu.android 24.12.26 (241226) debug
Android com.example.vu.android 24.12.26 (241226) release

⚙️ android Build Distribution Settings

@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (21c77a4) to head (fc1d313).

Files with missing lines Patch % Lines
...in/java/com/example/vu/android/MyBaseActivity.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #257   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         16      16           
  Lines        883     883           
  Branches      67      67           
=====================================
  Misses       883     883           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant