Skip to content

Commit f1aaaa9

Browse files
committed
Issue hypfvieh#44: Check arguments in array for null values to avoid NullPointerExceptions when calling .toString() on Message.class
1 parent 456183b commit f1aaaa9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • dbus-java/src/main/java/org/freedesktop/dbus/messages

dbus-java/src/main/java/org/freedesktop/dbus/messages/Message.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,9 @@ public String toString() {
460460
sb.append('}');
461461
} else {
462462
for (Object o : largs) {
463-
if (o instanceof Object[]) {
463+
if (o == null) {
464+
sb.append("null");
465+
} else if (o instanceof Object[]) {
464466
sb.append(Arrays.deepToString((Object[]) o));
465467
} else if (o instanceof byte[]) {
466468
sb.append(Arrays.toString((byte[]) o));
@@ -477,7 +479,7 @@ public String toString() {
477479
} else if (o instanceof float[]) {
478480
sb.append(Arrays.toString((float[]) o));
479481
} else {
480-
sb.append(o.toString());
482+
sb.append(o);
481483
}
482484
sb.append(',');
483485
sb.append(' ');
@@ -669,7 +671,7 @@ private int appendone(byte[] sigb, int sigofs, Object data) throws DBusException
669671
int diff = i;
670672
Map<Object, Object> map = (Map<Object, Object>) data;
671673
ensureBuffers(map.size() * 6);
672-
for (Map.Entry<Object, Object> o : map.entrySet()) {
674+
for (Map.Entry<Object, Object> o : map.entrySet()) {
673675
diff = appendone(sigb, i, o);
674676
}
675677
if (map.size() == 0) {
@@ -1393,4 +1395,4 @@ public interface Endian {
13931395
byte BIG = 'B';
13941396
byte LITTLE = 'l';
13951397
}
1396-
}
1398+
}

0 commit comments

Comments
 (0)