Closed Bug 1519686 Opened 6 years ago Closed 6 years ago

nsTSubstring::mData will be cleaned when using searchPath.BeginWriting() to write data.

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1516554

People

(Reporter: daoshengmu, Unassigned)

References

Details

Attachments

(1 file)

Per https://searchfox.org/mozilla-central/rev/7d7aca6a935f0725f35050fdaa3dd7a1b05d8d38/gfx/vr/service/OculusSession.cpp#539, we was using "int realLen =
::GetSystemDirectoryW(char16ptr_t(searchPath.BeginWriting()), pathLen);" to get the system path, "C:\WINDOWS\system32", and its length is 19.

Then using nsTSubstring::SetLength() to update its real length, but its old data will be cleaned at nsTSubstring<T>::StartBulkWriteImpl(). It looks like a regression from Bug 1483603.

Blocks: 1483603
Blocks: 1516554
Flags: needinfo?(hsivonen)

(In reply to Daosheng Mu[:daoshengmu] from comment #0)

Per https://searchfox.org/mozilla-central/rev/7d7aca6a935f0725f35050fdaa3dd7a1b05d8d38/gfx/vr/service/OculusSession.cpp#539, we was using "int realLen =
::GetSystemDirectoryW(char16ptr_t(searchPath.BeginWriting()), pathLen);" to get the system path, "C:\WINDOWS\system32", and its length is 19.

Then using nsTSubstring::SetLength() to update its real length, but its old data will be cleaned at nsTSubstring<T>::StartBulkWriteImpl(). It looks like a regression from Bug 1483603.

That pattern is documented not to be OK:
https://searchfox.org/mozilla-central/source/xpcom/string/nsTSubstring.h#342

See bug 1489462 for how to fix.

Flags: needinfo?(hsivonen)
Component: XPCOM → Graphics

I will land this patch at Bug 1516554, thanks.

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: