libaums
libaums copied to clipboard
OutOfMemoryError FAT.getChain()
This has happened on some devices, I have no further information at the moment.
java.lang.OutOfMemoryError:
at java.util.Arrays.copyOf (Arrays.java:3139)
at java.util.Arrays.copyOf (Arrays.java:3109)
at java.util.ArrayList.grow (ArrayList.java:275)
at java.util.ArrayList.ensureExplicitCapacity (ArrayList.java:249)
at java.util.ArrayList.ensureCapacityInternal (ArrayList.java:241)
at java.util.ArrayList.add (ArrayList.java:467)
at com.github.mjdev.libaums.fs.fat32.FAT.getChain$libaums_release (SourceFile:6)
at com.github.mjdev.libaums.fs.fat32.ClusterChain.
I think on some devices this loop never ends.
FAT.kt
do {
result.add(currentCluster)
offset = (fatOffset[0] + currentCluster * 4) / bufferSize * bufferSize
offsetInBlock = (fatOffset[0] + currentCluster * 4) % bufferSize
// if we have a new offset we are forced to read again
if (lastOffset != offset) {
buffer.clear()
blockDevice.read(offset, buffer)
lastOffset = offset
}
currentCluster = (buffer.getInt(offsetInBlock.toInt()) and 0x0FFFFFFF).toLong()
} while (currentCluster < FAT32_EOF_CLUSTER)
.. therefore it does not stop adding elements to the list:
result.add (currentCluster)
Seems that there is no end marker in the cluster chain Might be related to #247
Fixed with v0.9.4