Bug 1340577 - Add release-grade assertions to various XPCOM string API implementations to avoid input causing an overflow. r=froydnj
This commit is contained in:
@@ -4,6 +4,15 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
nsTDependentString_CharT::nsTDependentString_CharT(const char_type* aStart,
|
||||
const char_type* aEnd)
|
||||
: string_type(const_cast<char_type*>(aStart),
|
||||
uint32_t(aEnd - aStart), F_TERMINATED)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!");
|
||||
AssertValidDependentString();
|
||||
}
|
||||
|
||||
void
|
||||
nsTDependentString_CharT::Rebind(const string_type& str, uint32_t startPos)
|
||||
{
|
||||
@@ -23,3 +32,10 @@ nsTDependentString_CharT::Rebind(const string_type& str, uint32_t startPos)
|
||||
|
||||
SetDataFlags(str.Flags() & (F_TERMINATED | F_LITERAL));
|
||||
}
|
||||
|
||||
void
|
||||
nsTDependentString_CharT::Rebind(const char_type* aStart, const char_type* aEnd)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(aStart <= aEnd, "Overflow!");
|
||||
Rebind(aStart, uint32_t(aEnd - aStart));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user