Diff

net/server.lua @ 999:c088139d8f05

net.server: Fix potential nil handler usage
author Matthew Wild <mwild1@gmail.com>
date Fri, 17 Apr 2009 16:11:11 +0100
parent 996:6fb96dffb2c1
child 1035:8cc7e4452b2b
child 1098:37ea264e133d
line wrap: on
line diff
--- a/net/server.lua	Sun Apr 12 19:05:55 2009 +0100
+++ b/net/server.lua	Fri Apr 17 16:11:11 2009 +0100
@@ -325,7 +325,9 @@
             if not ( forced or fatalerror ) then
                 handler.sendbuffer( )
                 if bufferqueuelen ~= 0 then   -- try again...
-                    handler.write = nil    -- ... but no further writing allowed
+                    if handler then
+                        handler.write = nil    -- ... but no further writing allowed
+                    end
                     toclose = true
                     return false
                 end
@@ -337,9 +339,11 @@
         socket:close( )
         _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
         _socketlist[ socket ] = nil
-        _writetimes[ handler ] = nil
-        _closelist[ handler ] = nil
-        handler = nil
+        if handler then
+            _writetimes[ handler ] = nil
+            _closelist[ handler ] = nil
+            handler = nil
+        end
         socket = nil
         mem_free( )
 	if server then