Closed Bug 2089973 Opened 14 days ago Closed 1 day ago

Fix a leak in HashStore.cpp debug logging

Categories

(Toolkit :: Safe Browsing, task)

task

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: Sylvestre, Assigned: ffayyaz, Mentored)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug, Whiteboard: [lang=c++])

Attachments

(1 external file)

Filing as a good first bug to learn workflows.

Inside if (aSize <= 4 && LOG_ENABLED()), the buffer returned by ToNewCString(aPrefixes) is never freed. Use aPrefixes.BeginReading() directly instead of allocating a copy (or free it with free() after logging).

Current code:

    const uint32_t* p =
        reinterpret_cast<const uint32_t*>(ToNewCString(aPrefixes));

Link to the code:
https://searchfox.org/firefox-main/source/toolkit/components/url-classifier/HashStore.cpp

To verify the fix:

./mach build
./mach gtest 'UrlClassifier*'

This was reported by Coverity Scan (CID 1434927). The analyzer will stop reporting it once the change lands.

Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html

Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.

Assignee: nobody → ffayyaz
Status: NEW → RESOLVED
Closed: 1 day ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: