diff options
author | Arisotura <thetotalworm@gmail.com> | 2020-06-16 14:09:54 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2020-06-16 14:09:54 +0200 |
commit | 91ff63a19435833034f800267fab4ea6af675414 (patch) | |
tree | 2e4f4c5a090846ec45572264d40c5486bf71d03c /src/frontend/qt_sdl | |
parent | 1101ed773bd9ed0b8024b987cc9e6621d58f8fea (diff) |
fix slirp crash when exiting without having inited slirp
also fix misc bugs
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r-- | src/frontend/qt_sdl/LAN_Socket.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/frontend/qt_sdl/LAN_Socket.cpp b/src/frontend/qt_sdl/LAN_Socket.cpp index 5477a7d..13a8eb1 100644 --- a/src/frontend/qt_sdl/LAN_Socket.cpp +++ b/src/frontend/qt_sdl/LAN_Socket.cpp @@ -52,7 +52,7 @@ volatile int RXNum; u32 IPv4ID; -Slirp* Ctx; +Slirp* Ctx = nullptr; const int FDListMax = 64; struct pollfd FDList[FDListMax]; @@ -164,6 +164,7 @@ void SlirpCbUnregisterPollFD(int fd, void* opaque) void SlirpCbNotify(void* opaque) { + printf("Slirp: notify???\n"); } SlirpCb cb = @@ -205,7 +206,11 @@ bool Init() void DeInit() { - slirp_cleanup(Ctx); + if (Ctx) + { + slirp_cleanup(Ctx); + Ctx = nullptr; + } } @@ -411,6 +416,8 @@ void HandleDNSFrame(u8* data, int len) int SendPacket(u8* data, int len) { + if (!Ctx) return 0; + if (len > 2048) { printf("LAN_SendPacket: error: packet too long (%d)\n", len); @@ -496,6 +503,8 @@ int SlirpCbGetREvents(int idx, void* opaque) int RecvPacket(u8* data) { + if (!Ctx) return 0; + int ret = 0; if (FDListSize > 0) |