From 72a6fd4d2a7a2242dc4af3a25a7a175995e7fa9b Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sat, 18 Jan 2020 10:35:50 -0500 Subject: Bug 1352082 - Avoid shifting a signed integer left in C++. Tag UXP Issue #1344 --- parser/html/nsHtml5AttributeName.cpp | 10 +++++----- parser/html/nsHtml5AttributeName.h | 2 +- parser/html/nsHtml5ElementName.cpp | 6 +++--- parser/html/nsHtml5ElementName.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'parser') diff --git a/parser/html/nsHtml5AttributeName.cpp b/parser/html/nsHtml5AttributeName.cpp index 7e1cb7dd0..f44112f46 100644 --- a/parser/html/nsHtml5AttributeName.cpp +++ b/parser/html/nsHtml5AttributeName.cpp @@ -95,7 +95,7 @@ nsHtml5AttributeName::COLONIFIED_LOCAL(nsIAtom* name, nsIAtom* suffix) return arr; } -nsIAtom** +nsIAtom** nsHtml5AttributeName::SAME_LOCAL(nsIAtom* name) { nsIAtom** arr = new nsIAtom*[4]; @@ -108,7 +108,7 @@ nsHtml5AttributeName::SAME_LOCAL(nsIAtom* name) nsHtml5AttributeName* nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner) { - int32_t hash = nsHtml5AttributeName::bufToHash(buf, length); + uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length); int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash); if (index < 0) { return nsHtml5AttributeName::createAttributeName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner)); @@ -122,11 +122,11 @@ nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length } } -int32_t +uint32_t nsHtml5AttributeName::bufToHash(char16_t* buf, int32_t len) { - int32_t hash2 = 0; - int32_t hash = len; + uint32_t hash2 = 0; + uint32_t hash = len; hash <<= 5; hash += buf[0] - 0x60; int32_t j = len; diff --git a/parser/html/nsHtml5AttributeName.h b/parser/html/nsHtml5AttributeName.h index e12fb35cc..cd2e72714 100644 --- a/parser/html/nsHtml5AttributeName.h +++ b/parser/html/nsHtml5AttributeName.h @@ -78,7 +78,7 @@ class nsHtml5AttributeName static nsIAtom** SAME_LOCAL(nsIAtom* name); static nsHtml5AttributeName* nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner); private: - static int32_t bufToHash(char16_t* buf, int32_t len); + static uint32_t bufToHash(char16_t* buf, int32_t len); int32_t* uri; nsIAtom** local; nsIAtom** prefix; diff --git a/parser/html/nsHtml5ElementName.cpp b/parser/html/nsHtml5ElementName.cpp index f997f4781..faed0c082 100644 --- a/parser/html/nsHtml5ElementName.cpp +++ b/parser/html/nsHtml5ElementName.cpp @@ -73,7 +73,7 @@ nsHtml5ElementName::isCustom() nsHtml5ElementName* nsHtml5ElementName::elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner) { - int32_t hash = nsHtml5ElementName::bufToHash(buf, length); + uint32_t hash = nsHtml5ElementName::bufToHash(buf, length); int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash); if (index < 0) { return new nsHtml5ReleasableElementName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner)); @@ -87,10 +87,10 @@ nsHtml5ElementName::elementNameByBuffer(char16_t* buf, int32_t offset, int32_t l } } -int32_t +uint32_t nsHtml5ElementName::bufToHash(char16_t* buf, int32_t len) { - int32_t hash = len; + uint32_t hash = len; hash <<= 5; hash += buf[0] - 0x60; int32_t j = len; diff --git a/parser/html/nsHtml5ElementName.h b/parser/html/nsHtml5ElementName.h index 99c6de323..b00d245a5 100644 --- a/parser/html/nsHtml5ElementName.h +++ b/parser/html/nsHtml5ElementName.h @@ -73,7 +73,7 @@ class nsHtml5ElementName bool isCustom(); static nsHtml5ElementName* elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner); private: - static int32_t bufToHash(char16_t* buf, int32_t len); + static uint32_t bufToHash(char16_t* buf, int32_t len); nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags); protected: explicit nsHtml5ElementName(nsIAtom* name); -- cgit v1.2.3