From ce89269d2294e41d716707e1149d4ecc3c85d153 Mon Sep 17 00:00:00 2001 From: Mike de Boer Date: Thu, 18 Jan 2018 16:54:29 +0100 Subject: [PATCH] Bug 1429490 - Since nsISerializationHelper.serializeToString may throw, catch the error to prevent loss of session data. r=ckerschb MozReview-Commit-ID: GOAFT4CpVrR --HG-- extra : rebase_source : 8885fc2c4dec92482ede4889fe4b0e26ca41baab --- toolkit/modules/sessionstore/Utils.jsm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/toolkit/modules/sessionstore/Utils.jsm b/toolkit/modules/sessionstore/Utils.jsm index 98f5b07cf948..759e6e05ac49 100644 --- a/toolkit/modules/sessionstore/Utils.jsm +++ b/toolkit/modules/sessionstore/Utils.jsm @@ -119,10 +119,17 @@ this.Utils = Object.freeze({ * @return {String} The base64 encoded principal data. */ serializePrincipal(principal) { - if (!principal) - return null; + let serializedPrincipal = null; - return serializationHelper.serializeToString(principal); + try { + if (principal) { + serializedPrincipal = serializationHelper.serializeToString(principal); + } + } catch (e) { + debug(`Failed to serialize principal '${principal}' ${e}`); + } + + return serializedPrincipal; }, /**