Closed Bug 372626 Opened 19 years ago Closed 18 years ago

getPrefSafe isn't safe

Categories

(Calendar :: Internal Components, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 377579

People

(Reporter: hyc, Unassigned)

Details

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a3pre) Gecko/20070302 SeaMonkey/1.5a Build Identifier: I'm seeing exceptions when retrieving non-existent preferences with calUtils.js:getPrefSafe(). I note that calendarUtils.js had a try/catch block for getPrefSafe but the version in calUtils.js doesn't. It probably should. (More fallout from Bug#366560) Reproducible: Always Something like this... diff -u -w -r1.15 calUtils.js --- calUtils.js 4 Mar 2007 10:27:48 -0000 1.15 +++ calUtils.js 5 Mar 2007 02:37:35 -0000 @@ -397,6 +397,8 @@ const nsIPrefBranch = Components.interfaces.nsIPrefBranch; const prefB = Components.classes["@mozilla.org/preferences-service;1"] .getService(nsIPrefBranch); + + try { switch (prefB.getPrefType(aPrefName)) { case nsIPrefBranch.PREF_BOOL: return prefB.getBoolPref(aPrefName); @@ -407,6 +409,9 @@ default: // includes nsIPrefBranch.PREF_INVALID return aDefault; } + } catch(ex) { + return aDefault; + } } /**
Version: unspecified → Trunk
Can somebody try to confirm this on TRUNK, please? At least on my Windows BRANCH build it works fine, i.e. getPrefType() returns 0 (INVALID) in the sketched case. However, if this turns out to be a regression on TRUNK, I would file this bug against Firefox/Preferences.
This is fixed by the patch in bug 377579
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.