Fix class cast exception #986

This commit is contained in:
J-Jamet
2021-05-09 22:29:46 +02:00
parent 89ffeaf03b
commit 74b236b317
3 changed files with 12 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
KeePassDX(3.0.0)
*
KeePassDX(2.10.1)
* Fix parcelable with custom data #986
KeePassDX(2.10.0)
* Manage new database format 4.1 #956

View File

@@ -12,7 +12,7 @@ android {
minSdkVersion 15
targetSdkVersion 30
versionCode = 77
versionName = "3.0.0"
versionName = "2.10.1"
multiDexEnabled true
testApplicationId = "com.kunzisoft.keepass.tests"

View File

@@ -42,8 +42,12 @@ object ParcelableUtil {
val size = parcel.readInt()
val map = HashMap<K, V>(size)
for (i in 0 until size) {
val key: K? = kClass.cast(parcel.readParcelable(kClass.classLoader))
val value: V? = vClass.cast(parcel.readParcelable(vClass.classLoader))
val key: K? = try {
parcel.readParcelable(kClass.classLoader)
} catch (e: Exception) { null }
val value: V? = try {
parcel.readParcelable(vClass.classLoader)
} catch (e: Exception) { null }
if (key != null && value != null)
map[key] = value
}
@@ -76,7 +80,9 @@ object ParcelableUtil {
val map = LinkedHashMap<String, V>(size)
for (i in 0 until size) {
val key: String? = parcel.readString()
val value: V? = parcel.readParcelable(vClass.classLoader)
val value: V? = try {
parcel.readParcelable(vClass.classLoader)
} catch (e: Exception) { null }
if (key != null && value != null)
map[key] = value
}