Skip to content

Fix OOM crash when importing large/corrupted .eap-config files - #180

Merged
SanderVeer merged 1 commit into
mainfrom
bugfix/eap-config-import-oom
Aug 10, 2026
Merged

SanderVeer merged 1 commit into
mainfrom
bugfix/eap-config-import-oom

Conversation

@SanderVeer

Copy link
Copy Markdown
Collaborator

Switch to the existing extensions.InputStream.readBytes(), which reads in fixed 4KB chunks instead of trusting available(). It was added alongside this same file-import feature but was never actually wired up, so the file was silently using the stdlib version all along causing crashes when importing .eap-config files with large logos included. Removing .close() as this was already handled by the extension function.

buildDeepLink() read the file with the stdlib InputStream.readBytes(),
which pre-sizes its ByteArrayOutputStream using available(). For some
content:// URIs that value is unreliable and can report a huge bogus
size, causing an immediate multi-hundred-MB allocation attempt and an
OutOfMemoryError (Crashlytics issue 375883fdcbf164622a8a6870d7988eba,
top crash of the last 30 days).

Switch to the existing extensions.InputStream.readBytes(), which reads
in fixed 4KB chunks instead of trusting available(). It was added
alongside this same file-import feature but was never actually wired
up, so the file was silently using the stdlib version all along.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent OOM crashes during .eap-config file import by ensuring the app uses the project’s safer InputStream.readBytes() extension (chunked reads) rather than the Kotlin stdlib readBytes() behavior, and by removing redundant manual stream closing.

Changes:

  • Import the app’s extensions.readBytes so the file-import path uses the chunked implementation.
  • Remove the explicit inputStream.close() since the extension function handles closing via use {}.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 204 to 208
val inputStream = context.contentResolver.openInputStream(fileUri) ?: return@withContext null
val bytes = inputStream.readBytes()
val configParser = AndroidConfigParser()
return@withContext try {
val provider = configParser.parse(bytes)
@SanderVeer
SanderVeer merged commit 91ec31d into main Aug 10, 2026
2 checks passed
@SanderVeer
SanderVeer deleted the bugfix/eap-config-import-oom branch August 10, 2026 13:11
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.

3 participants