Commit b1fb9e90 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[serializer] Fix ExternalReferenceEncoder::NameOfAddress.

This function didn't account for addresses of api-provided external
references, leading to out-of-bound reads on external_reference_table.
(This happened to me when printing a code object in gdb, I'm not sure
how to easily test it.)

Also remove an unused method from the private Value class.

R=jgruber@chromium.org

Change-Id: Id14fed3fb3866df750bcad8f4a02c61748b07ad3
Reviewed-on: https://chromium-review.googlesource.com/1060035Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53195}
parent 50b2ecf9
...@@ -87,8 +87,9 @@ const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, ...@@ -87,8 +87,9 @@ const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate,
Address address) const { Address address) const {
Maybe<uint32_t> maybe_index = map_->Get(address); Maybe<uint32_t> maybe_index = map_->Get(address);
if (maybe_index.IsNothing()) return "<unknown>"; if (maybe_index.IsNothing()) return "<unknown>";
return isolate->heap()->external_reference_table()->name( Value value(maybe_index.FromJust());
maybe_index.FromJust()); if (value.is_from_api()) return "<from api>";
return isolate->heap()->external_reference_table()->name(value.index());
} }
void SerializedData::AllocateData(uint32_t size) { void SerializedData::AllocateData(uint32_t size) {
......
...@@ -30,7 +30,6 @@ class ExternalReferenceEncoder { ...@@ -30,7 +30,6 @@ class ExternalReferenceEncoder {
bool is_from_api() const { return IsFromAPI::decode(value_); } bool is_from_api() const { return IsFromAPI::decode(value_); }
uint32_t index() const { return Index::decode(value_); } uint32_t index() const { return Index::decode(value_); }
uint32_t raw() const { return value_; }
private: private:
class Index : public BitField<uint32_t, 0, 31> {}; class Index : public BitField<uint32_t, 0, 31> {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment