Closed Bug 1800050 Opened 2 years ago Closed 1 year ago

malloc vs operator delete [] mismatch in WriteCachedStencil

Categories

(Core :: JavaScript Engine, task, P1)

task

Tracking

()

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: arai, Assigned: arai)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

https://bugzilla.mozilla.org/show_bug.cgi?id=1799250#c4

JS::TranscodeBuffer::extractOrCopyRawBuffer returns a buffer allocated with malloc, and it needs free.
WriteCachedStencil receives the buffer into UniquePtr<char[]>, which uses delete[].

(as pointed out in https://bugzilla.mozilla.org/show_bug.cgi?id=1799250#c7 , this doesn't need immediate fix)

Possible solutions are:

  1. always copy the JS::TranscodeBuffer content into a new buffer allocated with new[]
  2. modify the JS::TranscodeBuffer to use new[]
  3. support free in StartupCache

1 is the simplest, but it needs extra copy.

FontNameCache::WriteCache also passes malloc-ed buffer to StartupCache::PutBuffer

https://searchfox.org/mozilla-central/rev/6f77213807eb5359c8afe458ac5628f973e92a25/gfx/thebes/gfxFT2FontList.cpp#725,747

void WriteCache() {
...
  mCache->PutBuffer(CACHE_KEY, UniquePtr<char[]>(ToNewCString(buf)),

Other places uses MakeUnique<char[]>.

I'll look into switching all consumers to use malloc/free.

Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Blocks: sm-runtime
Severity: -- → N/A
Priority: -- → P2
Priority: P2 → P1
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/02350fa31397
Use UniqueFreePtr in StartupCache::PutBuffer. r=nbp
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: