diff --git a/dom/icc/IccCallback.cpp b/dom/icc/IccCallback.cpp index 956559919ea..ad66f44ffff 100644 --- a/dom/icc/IccCallback.cpp +++ b/dom/icc/IccCallback.cpp @@ -38,7 +38,10 @@ IccContactToMozContact(JSContext* aCx, GlobalObject& aGlobal, if (count > 0) { Sequence& nameSeq = properties.mName.Construct().SetValue(); for (uint32_t i = 0; i < count; i++) { - nameSeq.AppendElement(nsDependentString(rawStringArray[i]), fallible); + nameSeq.AppendElement( + rawStringArray[i] ? nsDependentString(rawStringArray[i]) + : EmptyString(), + fallible); } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray); } @@ -52,7 +55,9 @@ IccContactToMozContact(JSContext* aCx, GlobalObject& aGlobal, Sequence& numberSeq = properties.mTel.Construct().SetValue(); for (uint32_t i = 0; i < count; i++) { ContactTelField number; - number.mValue.Construct() = nsDependentString(rawStringArray[i]); + number.mValue.Construct() = + rawStringArray[i] ? nsDependentString(rawStringArray[i]) + : EmptyString(); numberSeq.AppendElement(number, fallible); } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray); @@ -67,7 +72,9 @@ IccContactToMozContact(JSContext* aCx, GlobalObject& aGlobal, Sequence& emailSeq = properties.mEmail.Construct().SetValue(); for (uint32_t i = 0; i < count; i++) { ContactField email; - email.mValue.Construct() = nsDependentString(rawStringArray[i]); + email.mValue.Construct() = + rawStringArray[i] ? nsDependentString(rawStringArray[i]) + : EmptyString(); emailSeq.AppendElement(email, fallible); } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray); diff --git a/dom/icc/IccContact.cpp b/dom/icc/IccContact.cpp index 300ac1db041..7ec035f7ed6 100644 --- a/dom/icc/IccContact.cpp +++ b/dom/icc/IccContact.cpp @@ -129,6 +129,11 @@ NS_IMETHODIMP IccContact::Get##_field(uint32_t* aCount, char16_t*** a##_field) return NS_ERROR_OUT_OF_MEMORY; \ } \ for (uint32_t i = 0; i < count; i++) { \ + if(m##_field[i].IsVoid()) { \ + (temp)[i] = nullptr; \ + continue; \ + } \ + \ (temp)[i] = ToNewUnicode(m##_field[i]); \ if (!(temp)[i]) { \ NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, temp); \ diff --git a/dom/icc/gonk/IccService.js b/dom/icc/gonk/IccService.js index 176952b7045..953c0ec73a7 100644 --- a/dom/icc/gonk/IccService.js +++ b/dom/icc/gonk/IccService.js @@ -86,13 +86,8 @@ function IccContact(aContact) { this._numbers = []; this._emails = []; - if (aContact.alphaId) { - this._names.push(aContact.alphaId); - } - - if (aContact.number) { - this._numbers.push(aContact.number); - } + this._names.push(aContact.alphaId); + this._numbers.push(aContact.number); let anrLen = aContact.anr ? aContact.anr.length : 0; for (let i = 0; i < anrLen; i++) { diff --git a/dom/icc/ipc/IccIPCUtils.cpp b/dom/icc/ipc/IccIPCUtils.cpp index 850019ca886..c311c22a8ff 100644 --- a/dom/icc/ipc/IccIPCUtils.cpp +++ b/dom/icc/ipc/IccIPCUtils.cpp @@ -51,7 +51,9 @@ IccIPCUtils::GetIccContactDataFromIccContact(nsIIccContact* aContact, NS_ENSURE_SUCCESS_VOID(rv); if (count > 0) { for (uint32_t i = 0; i < count; i++) { - aOutData.names().AppendElement(nsDependentString(rawStringArray[i])); + aOutData.names().AppendElement( + rawStringArray[i] ? nsDependentString(rawStringArray[i]) + : NullString()); } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray); } @@ -63,7 +65,9 @@ IccIPCUtils::GetIccContactDataFromIccContact(nsIIccContact* aContact, NS_ENSURE_SUCCESS_VOID(rv); if (count > 0) { for (uint32_t i = 0; i < count; i++) { - aOutData.numbers().AppendElement(nsDependentString(rawStringArray[i])); + aOutData.numbers().AppendElement( + rawStringArray[i] ? nsDependentString(rawStringArray[i]) + : NullString()); } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray); } @@ -75,7 +79,9 @@ IccIPCUtils::GetIccContactDataFromIccContact(nsIIccContact* aContact, NS_ENSURE_SUCCESS_VOID(rv); if (count > 0) { for (uint32_t i = 0; i < count; i++) { - aOutData.emails().AppendElement(nsDependentString(rawStringArray[i])); + aOutData.emails().AppendElement( + rawStringArray[i] ? nsDependentString(rawStringArray[i]) + : NullString()); } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray); } diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 307bfde631c..3732e074abb 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -8689,7 +8689,7 @@ ICCPDUHelperObject.prototype = { * 0xff. * @param str String to be written. Could be null. * - * @return The string has been written into Buf. + * @return The string has been written into Buf. "" if str is null. */ writeStringTo8BitUnpacked: function(numOctets, str) { const langTable = PDU_NL_LOCKING_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT]; @@ -8729,7 +8729,7 @@ ICCPDUHelperObject.prototype = { GsmPDUHelper.writeHexOctet(0xff); } - return (str) ? str.substring(0, i) : null; + return (str) ? str.substring(0, i) : ""; }, /** @@ -9090,7 +9090,7 @@ ICCPDUHelperObject.prototype = { */ writeAlphaIdentifier: function(numOctets, alphaId) { if (numOctets === 0) { - return null; + return ""; } // If alphaId is empty or it's of GSM 8 bit. @@ -9222,7 +9222,7 @@ ICCPDUHelperObject.prototype = { for (let i = 0; i < ADN_MAX_BCD_NUMBER_BYTES + 1; i++) { GsmPDUHelper.writeHexOctet(0xff); } - return null; + return ""; } } };