Skip to content

Commit ecc3056

Browse files
committed
---
yaml --- r: 96932 b: refs/heads/dist-snap c: e121d75 h: refs/heads/master v: v3
1 parent 21972b7 commit ecc3056

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 51c03c1f35f6b076928a1e5b94ec81e6d00c3ac2
9+
refs/heads/dist-snap: e121d7556cc577c7a89acb3a609fcafcc8fc9204
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustuv/uvio.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ impl UvEventLoop {
5757
UvEventLoop {
5858
uvio: UvIoFactory {
5959
loop_: loop_,
60-
handle_pool: handle_pool,
60+
handle_pool: Some(handle_pool),
6161
}
6262
}
6363
}
6464
}
6565

6666
impl Drop for UvEventLoop {
6767
fn drop(&mut self) {
68+
// Must first destroy the pool of handles before we destroy the loop
69+
// because otherwise the contained async handle will be destroyed after
70+
// the loop is free'd (use-after-free)
71+
self.uvio.handle_pool.take();
6872
self.uvio.loop_.close();
6973
}
7074
}
@@ -117,14 +121,14 @@ fn test_callback_run_once() {
117121

118122
pub struct UvIoFactory {
119123
loop_: Loop,
120-
priv handle_pool: ~QueuePool,
124+
priv handle_pool: Option<~QueuePool>,
121125
}
122126

123127
impl UvIoFactory {
124128
pub fn uv_loop<'a>(&mut self) -> *uvll::uv_loop_t { self.loop_.handle }
125129

126130
pub fn make_handle(&mut self) -> HomeHandle {
127-
HomeHandle::new(self.id(), &mut *self.handle_pool)
131+
HomeHandle::new(self.id(), &mut **self.handle_pool.get_mut_ref())
128132
}
129133
}
130134

0 commit comments

Comments
 (0)