]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: Fix potential null pointer dereference in string.joinv()
authorPhilip Withnall <withnall@endlessm.com>
Tue, 5 Dec 2017 11:59:32 +0000 (11:59 +0000)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 9 Dec 2017 13:34:50 +0000 (14:34 +0100)
The logic in the ‘is the array null or empty’ check was disjunctive
rather than conjunctive. If (str_array == null), the condition would
have short-circuited and tried to evaluate str_array.length, which would
have crashed.

Coverity CID: #1462389 (spotted when scanning Tracker)

https://bugzilla.gnome.org/show_bug.cgi?id=791257

vapi/glib-2.0.vapi

index 76395cddbc3c1db01d7bc0e092266e4b0ec3d20b..fd1cfe3248ac4caf576b9fd0161467503551f2fa 100644 (file)
@@ -1062,7 +1062,7 @@ public class string {
                if (separator == null) {
                        separator = "";
                }
-               if (str_array != null || str_array.length > 0 || (str_array.length == -1 && str_array[0] != null)) {
+               if (str_array != null && (str_array.length > 0 || (str_array.length == -1 && str_array[0] != null))) {
                        int i;
                        size_t len = 1;
                        for (i = 0 ; (str_array.length != -1 && i < str_array.length) || (str_array.length == -1 && str_array[i] != null) ; i++) {