core: Fix panic when socket is closed before connecting
This commit is contained in:
parent
b46cc2aadc
commit
568d8dfe11
|
@ -125,25 +125,21 @@ impl<'gc> Sockets<'gc> {
|
||||||
match action {
|
match action {
|
||||||
SocketAction::Connect(handle, success) => {
|
SocketAction::Connect(handle, success) => {
|
||||||
if success {
|
if success {
|
||||||
let target = activation
|
let target = match activation.context.sockets.sockets.get(handle) {
|
||||||
.context
|
Some(socket) => socket.target,
|
||||||
.sockets
|
// Socket must have been closed before we could send event.
|
||||||
.sockets
|
None => continue,
|
||||||
.get(handle)
|
};
|
||||||
.expect("only valid handles in SocketAction")
|
|
||||||
.target;
|
|
||||||
|
|
||||||
let connect_evt =
|
let connect_evt =
|
||||||
EventObject::bare_default_event(&mut activation.context, "connect");
|
EventObject::bare_default_event(&mut activation.context, "connect");
|
||||||
Avm2::dispatch_event(&mut activation.context, connect_evt, target.into());
|
Avm2::dispatch_event(&mut activation.context, connect_evt, target.into());
|
||||||
} else {
|
} else {
|
||||||
let target = activation
|
let target = match activation.context.sockets.sockets.get(handle) {
|
||||||
.context
|
Some(socket) => socket.target,
|
||||||
.sockets
|
// Socket must have been closed before we could send event.
|
||||||
.sockets
|
None => continue,
|
||||||
.get(handle)
|
};
|
||||||
.expect("only valid handles in SocketAction")
|
|
||||||
.target;
|
|
||||||
|
|
||||||
let io_error_evt = activation
|
let io_error_evt = activation
|
||||||
.avm2()
|
.avm2()
|
||||||
|
|
Loading…
Reference in New Issue