make dnsasync better handle cleanup of a partially constructed instance
[lcore.git] / dnsasync.pas
index 8c3ce3a01d4afca44a754a3f268ca826fb6452ed..a8e1aa654b6d56778f3b9c9c11c3062bc534d4d8 100755 (executable)
@@ -100,12 +100,14 @@ var
   socketno : integer;\r
 begin\r
   for socketno := 0 to numsock -1 do begin\r
   socketno : integer;\r
 begin\r
   for socketno := 0 to numsock -1 do begin\r
-    if dnsserverids[socketno] >= 0 then begin\r
-      reportlag(dnsserverids[socketno],-1);\r
-      dnsserverids[socketno] := -1;\r
-    end;\r
-    sockets[socketno].release;\r
-    setstate_request_init('',states[socketno]);\r
+    if assigned(sockets[socketno]) then begin
+      if dnsserverids[socketno] >= 0 then begin\r
+        reportlag(dnsserverids[socketno],-1);\r
+        dnsserverids[socketno] := -1;\r
+      end;\r
+      sockets[socketno].release;\r
+      setstate_request_init('',states[socketno]);\r
+    end;
   end;\r
   inherited destroy;\r
 end;\r
   end;\r
   inherited destroy;\r
 end;\r