Skip to content

Commit

Permalink
100% safe pref access in limiter. Closes #1233, #1236
Browse files Browse the repository at this point in the history
  • Loading branch information
F43nd1r committed Sep 1, 2023
1 parent c774637 commit 3a1970c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ class LimiterStartupProcessor : HasConfigPlugin(LimiterConfiguration::class.java
if (limiterConfiguration.deleteReportsOnAppUpdate || limiterConfiguration.resetLimitsOnAppUpdate) {
val prefs = SharedPreferencesFactory(context, config).create()
val lastVersionNr = try {
prefs.getLong(ACRA.PREF_LAST_VERSION_NR, 0)
} catch (e: ClassCastException) {
prefs.getInt(ACRA.PREF_LAST_VERSION_NR, 0).toLong()
try {
prefs.getLong(ACRA.PREF_LAST_VERSION_NR, 0)
} catch (e: ClassCastException) {
prefs.getInt(ACRA.PREF_LAST_VERSION_NR, 0).toLong()
}
} catch (e: Exception) {
0
}
val appVersion = getAppVersion(context)
if (appVersion > lastVersionNr) {
Expand Down

0 comments on commit 3a1970c

Please sign in to comment.