[JPS] Improved processing of broken caches

If serialized metadata version has evidently incorrect size the module
should be marked for rebuild prior to reading serialized version.

#KT-42194 Fixed
This commit is contained in:
Andrey Uskov
2021-09-20 09:58:42 +03:00
committed by teamcityserver
parent 5d56bd545e
commit 4ad828f80f
2 changed files with 12 additions and 2 deletions
@@ -39,7 +39,11 @@ class ModuleMapping private constructor(
fun readVersionNumber(stream: DataInputStream): IntArray? =
try {
IntArray(stream.readInt()) { stream.readInt() }
val size = stream.readInt()
if (size < 0 || size > BinaryVersion.MAX_LENGTH)
null // cache is evidently corrupted
else
IntArray(size) { stream.readInt() }
} catch (e: IOException) {
null
}