Skip to content

Commit

Permalink
Only read symbol_id for strings which are known to be symbols
Browse files Browse the repository at this point in the history
Ensures that uninitialised symbol_id is not dereferenced if the
string is created on the stack via code generators instead of on
the heap.

Task-number: QTBUG-23126
Change-Id: I083586ad46796e70b0246413742d326c60f379e5
Reviewed-by: Peter Varga <[email protected]>
  • Loading branch information
Chris Adams authored and Qt by Nokia committed Aug 9, 2012
1 parent f489fb6 commit 30662b5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion src/3rdparty/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3911,7 +3911,7 @@ String::CompleteHashData String::CompleteHash() const {
CompleteHashData result;
result.length = str->length();
result.hash = str->Hash();
if (str->IsSeqString())
if (str->IsSeqAsciiString() && str->IsSymbol())
result.symbol_id = i::SeqString::cast(*str)->symbol_id();
return result;
}
Expand Down
2 changes: 0 additions & 2 deletions src/3rdparty/v8/src/heap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ MaybeObject* Heap::AllocateAsciiSymbol(Vector<const char> str,
String* answer = String::cast(result);
answer->set_length(str.length());
answer->set_hash_field(hash_field);
SeqString::cast(answer)->set_symbol_id(0);

ASSERT_EQ(size, answer->Size());

Expand Down Expand Up @@ -161,7 +160,6 @@ MaybeObject* Heap::AllocateTwoByteSymbol(Vector<const uc16> str,
String* answer = String::cast(result);
answer->set_length(str.length());
answer->set_hash_field(hash_field);
SeqString::cast(answer)->set_symbol_id(0);

ASSERT_EQ(size, answer->Size());

Expand Down
2 changes: 0 additions & 2 deletions src/3rdparty/v8/src/heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4490,7 +4490,6 @@ MaybeObject* Heap::AllocateRawAsciiString(int length, PretenureFlag pretenure) {
HeapObject::cast(result)->set_map_no_write_barrier(ascii_string_map());
String::cast(result)->set_length(length);
String::cast(result)->set_hash_field(String::kEmptyHashField);
SeqString::cast(result)->set_symbol_id(0);
ASSERT_EQ(size, HeapObject::cast(result)->Size());
return result;
}
Expand Down Expand Up @@ -4527,7 +4526,6 @@ MaybeObject* Heap::AllocateRawTwoByteString(int length,
HeapObject::cast(result)->set_map_no_write_barrier(string_map());
String::cast(result)->set_length(length);
String::cast(result)->set_hash_field(String::kEmptyHashField);
SeqString::cast(result)->set_symbol_id(0);
ASSERT_EQ(size, HeapObject::cast(result)->Size());
return result;
}
Expand Down

0 comments on commit 30662b5

Please sign in to comment.