From f0cfaedb01508259ac8abe370da8bad472f4701e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 22 Feb 2015 18:37:44 -0800 Subject: [PATCH] Remove canary Destructors are sound now, so this is no longer necessary --- src/lib.rs | 12 ------------ src/macros.rs | 3 --- 2 files changed, 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 582e5c36..23744c03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -100,7 +100,6 @@ mod url; mod util; pub mod types; -const CANARY: u32 = 0xdeadbeef; const TYPEINFO_QUERY: &'static str = "t"; /// A type alias of the result returned by many methods. @@ -398,7 +397,6 @@ struct InnerConnection { parameters: HashMap, next_stmt_id: u32, trans_depth: u32, - canary: u32, desynchronized: bool, finished: bool, } @@ -433,7 +431,6 @@ impl InnerConnection { desynchronized: false, finished: false, trans_depth: 0, - canary: CANARY, }; options.push(("client_encoding".to_owned(), "UTF8".to_owned())); @@ -797,10 +794,6 @@ impl InnerConnection { self.desynchronized } - fn canary(&self) -> u32 { - self.canary - } - fn wait_for_ready(&mut self) -> Result<()> { match try!(self.read_message()) { ReadyForQuery { .. } => Ok(()), @@ -840,7 +833,6 @@ impl InnerConnection { fn finish_inner(&mut self) -> Result<()> { check_desync!(self); - self.canary = 0; try!(self.write_messages(&[Terminate])); Ok(()) } @@ -1142,10 +1134,6 @@ impl Connection { conn.finish_inner() } - fn canary(&self) -> u32 { - self.conn.borrow().canary() - } - fn write_messages(&self, messages: &[FrontendMessage]) -> IoResult<()> { self.conn.borrow_mut().write_messages(messages) } diff --git a/src/macros.rs b/src/macros.rs index fd2074b2..f9d5eaaf 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -12,9 +12,6 @@ macro_rules! try_desync { macro_rules! check_desync { ($e:expr) => ({ - if $e.canary() != CANARY { - panic!("Connection use after free. See mozilla/rust#13246."); - } if $e.is_desynchronized() { return Err(::Error::StreamDesynchronized); }