mirror of
https://github.com/google/leveldb.git
synced 2025-02-04 07:10:10 +08:00
Fix speculatively some "placement new" issues in leveldb
cl/713346733 changed the type of some variables to pointers, but didn't adjust the placement new statements. From pkasting@: "I suspect your code is wrong and will crash. An array is a pointer, so taking its address also gives a pointer, which is why it compiles; but the value of that pointer is different. You're no longer providing the address of the storage, but rather the address of the array pointer." PiperOrigin-RevId: 717926210
This commit is contained in:
parent
302786e211
commit
e829478c6a
@ -880,7 +880,7 @@ class SingletonEnv {
|
||||
"env_storage_ does not meet the Env's alignment needs");
|
||||
static_assert(alignof(SingletonEnv<EnvType>) % alignof(EnvType) == 0,
|
||||
"env_storage_ does not meet the Env's alignment needs");
|
||||
new (&env_storage_) EnvType();
|
||||
new (env_storage_) EnvType();
|
||||
}
|
||||
~SingletonEnv() = default;
|
||||
|
||||
|
@ -775,7 +775,7 @@ class SingletonEnv {
|
||||
"env_storage_ does not meet the Env's alignment needs");
|
||||
static_assert(alignof(SingletonEnv<EnvType>) % alignof(EnvType) == 0,
|
||||
"env_storage_ does not meet the Env's alignment needs");
|
||||
new (&env_storage_) EnvType();
|
||||
new (env_storage_) EnvType();
|
||||
}
|
||||
~SingletonEnv() = default;
|
||||
|
||||
|
@ -28,7 +28,7 @@ class NoDestructor {
|
||||
static_assert(
|
||||
alignof(NoDestructor<InstanceType>) % alignof(InstanceType) == 0,
|
||||
"instance_storage_ does not meet the instance's alignment requirement");
|
||||
new (&instance_storage_)
|
||||
new (instance_storage_)
|
||||
InstanceType(std::forward<ConstructorArgTypes>(constructor_args)...);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user