[GH-ISSUE #395] Potential for NullPointerException when receiving SMS #281

Closed
opened 2026-02-28 01:23:59 +03:00 by kerem · 0 comments
Owner

Originally created by @alxndrsn on GitHub (Apr 6, 2016).
Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/395

In SmsReceiverService.handleSmsReceived(), there is potential for a NullPointerException if the result of getMessagesFromIntent() is ever null, because the first array element is dereferenced before the null check:

            sms = messages[0];
            if (messages != null) {
                ...

Either the null check is unnecessary, or these two lines should change order.

Originally created by @alxndrsn on GitHub (Apr 6, 2016). Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/395 In [`SmsReceiverService.handleSmsReceived()`](https://github.com/ushahidi/SMSSync/blob/master/smssync/src/main/java/org/addhen/smssync/presentation/service/SmsReceiverService.java#L248), there is potential for a `NullPointerException` if the result of [`getMessagesFromIntent()`](https://developer.android.com/reference/android/provider/Telephony.Sms.Intents.html#getMessagesFromIntent%28android.content.Intent%29) is ever `null`, because the first array element is dereferenced before the null check: ``` java sms = messages[0]; if (messages != null) { ... ``` Either the null check is unnecessary, or these two lines should change order.
kerem closed this issue 2026-02-28 01:23:59 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SMSSync#281
No description provided.