зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1595886 - Use a temp string in readSegments r=dragana
Differential Revision: https://phabricator.services.mozilla.com/D68204 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2a69bde525
Коммит
b5c0442d4e
|
@ -305,8 +305,23 @@ nsStringInputStream::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure,
|
|||
if (aCount > maxCount) {
|
||||
aCount = maxCount;
|
||||
}
|
||||
|
||||
nsDependentCSubstring tempData;
|
||||
tempData.SetIsVoid(true);
|
||||
if (mData.GetDataFlags() & nsACString::DataFlags::OWNED) {
|
||||
tempData.Assign(std::move(mData));
|
||||
mData.Rebind(tempData.BeginReading(), tempData.EndReading());
|
||||
}
|
||||
|
||||
nsresult rv = aWriter(this, aClosure, mData.BeginReading() + mOffset, 0,
|
||||
aCount, aResult);
|
||||
|
||||
if (!mData.IsVoid() && !tempData.IsVoid()) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mData == tempData, "String was replaced!");
|
||||
mData.SetIsVoid(true);
|
||||
mData.Assign(std::move(tempData));
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
NS_ASSERTION(*aResult <= aCount,
|
||||
"writer should not write more than we asked it to write");
|
||||
|
|
Загрузка…
Ссылка в новой задаче