mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8249087: Always initialize _body[0..1] in Symbol constructor
Reviewed-by: dholmes, lfoltan
This commit is contained in:
parent
831e98327b
commit
112bbcb396
1 changed files with 6 additions and 1 deletions
|
@ -51,7 +51,12 @@ uint32_t Symbol::pack_hash_and_refcount(short hash, int refcount) {
|
||||||
Symbol::Symbol(const u1* name, int length, int refcount) {
|
Symbol::Symbol(const u1* name, int length, int refcount) {
|
||||||
_hash_and_refcount = pack_hash_and_refcount((short)os::random(), refcount);
|
_hash_and_refcount = pack_hash_and_refcount((short)os::random(), refcount);
|
||||||
_length = length;
|
_length = length;
|
||||||
_body[0] = 0; // in case length == 0
|
// _body[0..1] are allocated in the header just by coincidence in the current
|
||||||
|
// implementation of Symbol. They are read by identity_hash(), so make sure they
|
||||||
|
// are initialized.
|
||||||
|
// No other code should assume that _body[0..1] are always allocated. E.g., do
|
||||||
|
// not unconditionally read base()[0] as that will be invalid for an empty Symbol.
|
||||||
|
_body[0] = _body[1] = 0;
|
||||||
memcpy(_body, name, length);
|
memcpy(_body, name, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue