Bug 1497612 - Baldr: add missing oom check for GetOptimizedBuildId (r=lth)

--HG--
extra : rebase_source : ad9e2129c8c1a69582c89a33edeb699dfa14f664
This commit is contained in:
Luke Wagner 2018-10-10 14:56:44 -05:00
Родитель f20d61be72
Коммит 505513089b
3 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -3529,7 +3529,7 @@ class OptimizedEncodingListener
virtual void storeOptimizedEncoding(const uint8_t* bytes, size_t length) = 0;
};
extern JS_PUBLIC_API(bool)
extern MOZ_MUST_USE JS_PUBLIC_API(bool)
GetOptimizedEncodingBuildId(BuildIdCharVector* buildId);
class JS_PUBLIC_API(StreamConsumer)

Просмотреть файл

@ -193,7 +193,12 @@ Module::testingBlockOnTier2Complete() const
Module::serializedSize(const LinkData& linkData) const
{
JS::BuildIdCharVector buildId;
JS::GetOptimizedEncodingBuildId(&buildId);
{
AutoEnterOOMUnsafeRegion oom;
if (!GetOptimizedEncodingBuildId(&buildId)) {
oom.crash("getting build id");
}
}
return SerializedPodVectorSize(buildId) +
linkData.serializedSize() +
@ -212,7 +217,12 @@ Module::serialize(const LinkData& linkData, uint8_t* begin, size_t size) const
MOZ_RELEASE_ASSERT(code_->hasTier(Tier::Serialized));
JS::BuildIdCharVector buildId;
JS::GetOptimizedEncodingBuildId(&buildId);
{
AutoEnterOOMUnsafeRegion oom;
if (!GetOptimizedEncodingBuildId(&buildId)) {
oom.crash("getting build id");
}
}
uint8_t* cursor = begin;
cursor = SerializePodVector(cursor, buildId);
@ -240,7 +250,9 @@ Module::deserialize(const uint8_t* begin, size_t size, Metadata* maybeMetadata)
const uint8_t* cursor = begin;
JS::BuildIdCharVector currentBuildId;
JS::GetOptimizedEncodingBuildId(&currentBuildId);
if (!GetOptimizedEncodingBuildId(&currentBuildId)) {
return nullptr;
}
JS::BuildIdCharVector deserializedBuildId;
cursor = DeserializePodVector(cursor, &deserializedBuildId);

Просмотреть файл

@ -195,7 +195,7 @@ typedef RefPtr<const Module> SharedModule;
// JS API implementations:
bool
MOZ_MUST_USE bool
GetOptimizedEncodingBuildId(JS::BuildIdCharVector* buildId);
RefPtr<JS::WasmModule>