From a38c63448471905e4857ea82765ec5baf30cb980 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Thu, 4 Apr 2013 15:21:49 -0700 Subject: [PATCH] Bug 858034 - Make navigator.getDeviceStorage('') not crash when device storage is disabled. r=bent --- dom/base/Navigator.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 79e30e1de0be..0e65fbe2a7c1 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -992,6 +992,13 @@ Navigator::MozIsLocallyAvailable(const nsAString &aURI, NS_IMETHODIMP Navigator::GetDeviceStorage(const nsAString &aType, nsIDOMDeviceStorage** _retval) { + NS_ENSURE_ARG_POINTER(_retval); + *_retval = nullptr; + + if (!Preferences::GetBool("device.storage.enabled", false)) { + return NS_OK; + } + // We're going to obsolete getDeviceStorage, but want to leave it in for // compatability right now. So we do essentially the same thing as GetDeviceStorages // but only take the first element of the array. @@ -1009,7 +1016,6 @@ NS_IMETHODIMP Navigator::GetDeviceStorage(const nsAString &aType, nsIDOMDeviceSt if (dataType != nsIDataType::VTYPE_ARRAY) { NS_ASSERTION(dataType == nsIDataType::VTYPE_EMPTY_ARRAY, "Expecting an empty array"); - *_retval = nullptr; return NS_OK; } @@ -1030,6 +1036,9 @@ NS_IMETHODIMP Navigator::GetDeviceStorage(const nsAString &aType, nsIDOMDeviceSt NS_IMETHODIMP Navigator::GetDeviceStorages(const nsAString &aType, nsIVariant** _retval) { + NS_ENSURE_ARG_POINTER(_retval); + *_retval = nullptr; + if (!Preferences::GetBool("device.storage.enabled", false)) { return NS_OK; }