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

Commit 562137aa authored by Moez Bhatti's avatar Moez Bhatti
Browse files

Fix crash when smsBody in cursor is null

parent b8deb288
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -88,7 +88,11 @@ class CursorToMessageImpl @Inject constructor(
                    address = cursor.getString(columnsMap.smsAddress) ?: ""
                    boxId = cursor.getInt(columnsMap.smsType)
                    seen = cursor.getInt(columnsMap.smsSeen) != 0
                    body = if (columnsMap.smsBody != -1) cursor.getString(columnsMap.smsBody) else null ?: ""

                    body = columnsMap.smsBody
                            .takeIf { column -> column != -1 } // The column may not be set
                            ?.let { column -> cursor.getString(column) } ?: "" // cursor.getString() may return null

                    errorCode = cursor.getInt(columnsMap.smsErrorCode)
                    deliveryStatus = cursor.getInt(columnsMap.smsStatus)
                }