Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit 0f77d6f

Browse files
committed
Use ptr::write() to initialize the GSource
Otherwise we might run a Drop impl on uninitialized memory.
1 parent 109acc8 commit 0f77d6f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main_context_futures.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
44

55
use std::mem;
6+
use std::ptr;
67
use std::sync::atomic::{AtomicUsize, Ordering};
78

89
use futures;
@@ -157,7 +158,7 @@ impl TaskSource {
157158
);
158159
{
159160
let source = &mut *(source as *mut TaskSource);
160-
source.future = Some((future, Box::new(LocalMap::new())));
161+
ptr::write(&mut source.future, Some((future, Box::new(LocalMap::new()))));
161162
source.thread = thread;
162163
source.state = AtomicUsize::new(INIT);
163164
}

0 commit comments

Comments
 (0)