gtkmountoperation-x11: Do array length check before dereference
authorPhilip Withnall <withnall@endlessm.com>
Mon, 11 Sep 2017 08:23:17 +0000 (09:23 +0100)
committerDaniel Boles <dboles@src.gnome.org>
Tue, 12 Sep 2017 20:15:53 +0000 (21:15 +0100)
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=787302

gtk/gtkmountoperation-x11.c

index 10c7bbcf81cd048d1e6179eed61d5f5f4887def7..adb47b16599d0c98c080e89b4d49a70aef5aae1d 100644 (file)
@@ -653,7 +653,7 @@ pid_get_env (GPid         pid,
       n = 0;
       while (TRUE)
         {
-          if (env[n] == '\0' || n >= env_len)
+          if (n >= env_len || env[n] == '\0')
             break;
 
           if (g_str_has_prefix (env + n, key) && (*(env + n + key_len) == '='))
@@ -666,7 +666,7 @@ pid_get_env (GPid         pid,
               break;
             }
 
-          for (; env[n] != '\0' && n < env_len; n++)
+          for (; n < env_len && env[n] != '\0'; n++)
             ;
           n++;
         }