Skip to content

Commit 278030d

Browse files
authored
Check against empty service ids.
1 parent 69b63a0 commit 278030d

File tree

1 file changed

+2
-2
lines changed
  • libsignal-service/src/main/java/org/whispersystems/signalservice/api/push

1 file changed

+2
-2
lines changed

libsignal-service/src/main/java/org/whispersystems/signalservice/api/push/ServiceId.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ sealed class ServiceId(val libSignalServiceId: LibSignalServiceId) {
6060
/** Parses a ServiceId serialized as a byte array. Returns null if the ServiceId is invalid. */
6161
@JvmStatic
6262
fun parseOrNull(raw: ByteArray?): ServiceId? {
63-
if (raw == null) {
63+
if (raw == null || raw.isEmpty()) {
6464
return null
6565
}
6666

@@ -222,7 +222,7 @@ sealed class ServiceId(val libSignalServiceId: LibSignalServiceId) {
222222
/** Parse a byte array as a PNI, regardless if it has the type prefix byte present or not. Only use this if you are certain what you're reading is a PNI. */
223223
@JvmStatic
224224
fun parseOrNull(raw: ByteArray?): PNI? {
225-
return if (raw == null) {
225+
return if (raw == null || raw.isEmpty()) {
226226
null
227227
} else if (raw.size == 17) {
228228
ServiceId.parseOrNull(raw).let { if (it is PNI) it else null }

0 commit comments

Comments
 (0)