mudgangster

Log | Files | Refs

commit 6e126f8e3b25c50d3d829a2cec9138458bd3dc29
parent f0398bf6ec8fe694b495433e124b5943fa66df0d
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Thu,  6 Sep 2018 13:18:31 +0300

Fix crash when sockets close

Diffstat:
src/win32.cc | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/win32.cc b/src/win32.cc @@ -652,8 +652,12 @@ LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { while( true ) { char buf[ 2048 ]; int n = recv( fd, buf, sizeof( buf ), 0 ); - if( n >= 0 ) { - script_socketData( sock, n > 0 ? buf : NULL, n ); + if( n > 0 ) { + script_socketData( sock, buf, n ); + } + else if( n == 0 ) { + script_socketData( sock, NULL, n ); + break; } else { int err = WSAGetLastError();