Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 7da39d98 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

People: Fix database leak

parent 5f8c4187
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -90,13 +90,15 @@ class AuthSignInActivity : AppCompatActivity() {
    }

    private fun getDisplayName(account: Account): String? {
        val cursor = DatabaseHelper(this).getOwner(account.name)
        val databaseHelper = DatabaseHelper(this)
        val cursor = databaseHelper.getOwner(account.name)
        return try {
            if (cursor.moveToNext()) {
                cursor.getColumnIndex("display_name").takeIf { it >= 0 }?.let { cursor.getString(it) }.takeIf { !it.isNullOrBlank() }
            } else null
        } finally {
            cursor.close()
            databaseHelper.close()
        }
    }

+3 −1
Original line number Diff line number Diff line
@@ -89,7 +89,8 @@ suspend fun performSignIn(context: Context, packageName: String, options: Google
    val obfuscatedIdentifier: String = MessageDigest.getInstance("MD5").digest("$googleUserId:$packageName".encodeToByteArray()).toHexString().uppercase()
    val grantedScopes = authResponse.grantedScopes?.split(" ").orEmpty().map { Scope(it) }.toSet()
    val (givenName, familyName, displayName, photoUrl) = if (includeProfile) {
        val cursor = DatabaseHelper(context).getOwner(account.name)
        val databaseHelper = DatabaseHelper(context)
        val cursor = databaseHelper.getOwner(account.name)
        try {
            if (cursor.moveToNext()) {
                listOf(
@@ -101,6 +102,7 @@ suspend fun performSignIn(context: Context, packageName: String, options: Google
            } else listOf(null, null, null, null)
        } finally {
            cursor.close()
            databaseHelper.close()
        }
    } else listOf(null, null, null, null)
    SignInConfigurationService.setDefaultAccount(context, packageName, account)