7130662: GTK file dialog crashes with a NPE

Guard adding a back slash to the directory name with an if (!= null) check

Reviewed-by: anthony, art
This commit is contained in:
Matt Smith 2012-01-18 19:09:26 +04:00 committed by Anthony Petrov
parent 36b3d034d2
commit d5d6252e5b

View File

@ -76,9 +76,12 @@ class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
accessor.setFiles(fd, null, 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]);
accessor.setFiles(fd, directory, filenames);
}