Commit a09168be authored by jochen's avatar jochen Committed by Commit bot

Don't use AddSubstring for external natives

The input string is not necessarily zero terminated

BUG=chromium:443230
R=adamk@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/795383003

Cr-Commit-Position: refs/heads/master@{#25879}
parent 7edd6efd
......@@ -82,15 +82,14 @@ class NativesStore {
NativesStore() : debugger_count_(0) {}
Vector<const char> NameFromId(const byte* id, int id_length) {
Vector<char> name(Vector<char>::New(id_length + 11));
SimpleStringBuilder builder(name.start(), name.length());
builder.AddString("native ");
builder.AddSubstring(reinterpret_cast<const char*>(id), id_length);
builder.AddString(".js");
builder.Finalize();
// SimpleStringBuilder wants zero-byte; the caller does not.
DCHECK(name[name.length() - 1] == '\0');
name.Truncate(name.length() - 1);
const char native[] = "native ";
const char extension[] = ".js";
Vector<char> name(Vector<char>::New(id_length + sizeof(native) - 1 +
sizeof(extension) - 1));
memcpy(name.start(), native, sizeof(native) - 1);
memcpy(name.start() + sizeof(native) - 1, id, id_length);
memcpy(name.start() + sizeof(native) - 1 + id_length, extension,
sizeof(extension) - 1);
return Vector<const char>::cast(name);
}
......
......@@ -863,7 +863,7 @@ class SimpleStringBuilder {
// compute the length of the input string.
void AddString(const char* s);
// Add the first 'n' characters of the given string 's' to the
// Add the first 'n' characters of the given 0-terminated string 's' to the
// builder. The input string must have enough characters.
void AddSubstring(const char* s, int n);
......
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