Skip to content

Commit

Permalink
Foxhound: Fixing memory leak due to untidy StringTaints
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbrbr committed Feb 23, 2024
1 parent 4a2b661 commit d85187f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5055,7 +5055,7 @@ void Element::TaintSelectorOperation(const char* operation, const nsAString& aEl
// Here we want to save a list of all selector operations performed on the element

// Check if there is a direct flow
const StringTaint aTaint = aElementId.Taint();
const StringTaint& aTaint = aElementId.Taint();
TaintFlow flow;
if (aTaint.hasTaint()) {
// Take the first range
Expand Down
4 changes: 2 additions & 2 deletions parser/html/nsHtml5StreamParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ nsresult nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
}
Buffer<uint8_t> data(std::move(*maybe));
StringTaint taint;
SafeStringTaint taint;
if (taintInputStream) {
rv = taintInputStream->TaintedRead(reinterpret_cast<char*>(data.Elements()),
data.Length(), &taint, &totalRead);
Expand Down Expand Up @@ -1684,7 +1684,7 @@ nsresult nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
return NS_ERROR_OUT_OF_MEMORY;
}
Buffer<uint8_t> data(std::move(*maybe));
StringTaint taint;
SafeStringTaint taint;

if (taintInputStream) {
rv = taintInputStream->TaintedRead(reinterpret_cast<char*>(data.Elements()),
Expand Down
1 change: 1 addition & 0 deletions parser/html/nsHtml5TreeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self) {
charBufferLen = 0;
charBuffer = nullptr;
framesetOk = true;
charTaint.clear();
if (fragment) {
nsIContentHandle* elt;
if (contextNode) {
Expand Down
2 changes: 1 addition & 1 deletion parser/html/nsHtml5UTF16Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class nsHtml5Portability;
class nsHtml5UTF16Buffer {
private:
char16_t* buffer;
StringTaint taint;
SafeStringTaint taint;
int32_t start;
int32_t end;

Expand Down

0 comments on commit d85187f

Please sign in to comment.