From 8444083c28b912945cba0a7203ca02082594d09b Mon Sep 17 00:00:00 2001 From: roytam1 Date: Sat, 14 Jul 2018 20:49:47 +0800 Subject: [PATCH] pref/main: _getDownloadsFolder() and fileLocator.get() can throw, wrap them with try-catch block --- browser/components/preferences/main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js index ef0ded86..e296a1f1 100644 --- a/browser/components/preferences/main.js +++ b/browser/components/preferences/main.js @@ -307,10 +307,12 @@ var gMainPane = { */ _folderToIndex: function (aFolder) { + try { if (!aFolder || aFolder.equals(this._getDownloadsFolder("Desktop"))) return 0; else if (aFolder.equals(this._getDownloadsFolder("Downloads"))) return 1; + } catch(e) {} return 2; }, @@ -326,8 +328,13 @@ var gMainPane = { { var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"] .getService(Components.interfaces.nsIProperties); - var dir = fileLocator.get(this._getSpecialFolderKey(aFolder), + var dir; + try { + dir = fileLocator.get(this._getSpecialFolderKey(aFolder), Components.interfaces.nsILocalFile); + } catch(e) { + dir = aFolder; + } if (aFolder != "Desktop") dir.append("My Downloads"); // XXX l12y!