File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -174,7 +174,9 @@ unsafe impl<S> Send for TlsStream<S> {}
174
174
impl < S > Drop for TlsStream < S > {
175
175
fn drop ( & mut self ) {
176
176
unsafe {
177
- Box :: from_raw ( self . session ) ;
177
+ if self . session != :: std:: ptr:: null_mut ( ) {
178
+ Box :: from_raw ( self . session ) ;
179
+ }
178
180
Box :: from_raw ( self . socket ) ;
179
181
180
182
Box :: from_raw ( self . ctx ) ;
@@ -426,6 +428,8 @@ impl<S> TlsStream<S> {
426
428
}
427
429
428
430
pub fn tls_server_end_point ( & self ) -> Result < Option < Vec < u8 > > , Error > {
431
+ // FIXME need to take server certificate in all cases, not always peer cert
432
+ // so this is broken for servers
429
433
let cert = match self . peer_certificate ( ) ? {
430
434
Some ( cert) => cert,
431
435
None => return Ok ( None ) ,
@@ -448,6 +452,10 @@ impl<S> TlsStream<S> {
448
452
449
453
pub fn shutdown ( & mut self ) -> io:: Result < ( ) > {
450
454
// Shutdown happens as a result of drop ...
455
+ unsafe {
456
+ Box :: from_raw ( self . session ) ;
457
+ self . session = :: std:: ptr:: null_mut ( ) ;
458
+ }
451
459
Ok ( ( ) )
452
460
}
453
461
}
You can’t perform that action at this time.
0 commit comments