Skip to content

Fix ArrayIndexOutOfBoundsException in MyBaseActivity.createTempFileSecure() - #252

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

Fix ArrayIndexOutOfBoundsException in MyBaseActivity.createTempFileSecure()#252
cursor[bot] wants to merge 1 commit into
mainfrom
arrayindexoutofboundsexception-length3-index3-q0wq49

Conversation

@cursor

@cursor cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Summary

Fixes an off-by-one error in the array bounds check that caused ArrayIndexOutOfBoundsException when accessing cache files.

Problem

The guard condition in createTempFileSecure() at line 163 used index > cacheFiles.length instead of index >= cacheFiles.length, allowing index values equal to the array length to pass the bounds check. Since Java arrays are 0-indexed with valid indices from 0 to length-1, an index equal to the array length would cause an ArrayIndexOutOfBoundsException when accessing the array.

Solution

Changed the guard condition from > to >= to properly reject index values that are out of bounds.

// Before:
while (indexes.contains(index) || index > cacheFiles.length || index < 0)

// After:
while (indexes.contains(index) || index >= cacheFiles.length || index < 0)

Testing

  • The fix prevents index values equal to cacheFiles.length from passing the guard
  • Valid indices (0 to length-1) continue to work correctly
  • Out-of-bounds access is now properly prevented

Fixes ANDROID-M7

Open in Web Open in Cursor 

…cure()

Change guard condition from 'index > cacheFiles.length' to 'index >= cacheFiles.length'
to properly reject index values equal to the array length. Since Java arrays are 0-indexed,
valid indices are 0 to length-1, so index == length must be rejected.

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

sentry Bot commented Aug 7, 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 7, 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 (2bef372) to head (e1855b9).

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    #252   +/-   ##
=====================================
  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