changeset 5851:885ad3351534

7130662: GTK file dialog crashes with a NPE Summary: Guard adding a back slash to the directory name with an if (!= null) check Reviewed-by: anthony, art Contributed-by: Matt <melkor@orangepalantir.org>
author anthony
date Wed, 18 Jan 2012 19:09:26 +0400
parents 1aa871010e23
children 95d1d08e82c1 1fc4a8d78ef7
files src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Tue Apr 02 12:01:35 2013 -0700
+++ b/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Wed Jan 18 19:09:26 2012 +0400
@@ -76,9 +76,12 @@
             accessor.setFiles(fd, null);
         } else {
             // Fix 6987233: add the trailing slash if it's absent
-            accessor.setDirectory(fd, directory +
-                    (directory.endsWith(File.separator) ?
-                     "" : File.separator));
+            String with_separator = directory;
+            if (directory != null) {
+                with_separator = directory.endsWith(File.separator) ?
+                        directory : (directory + File.separator);
+            }
+            accessor.setDirectory(fd, with_separator);
             accessor.setFile(fd, filenames[0]);
 
             int filesNumber = (filenames != null) ? filenames.length : 0;