summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/nativesockets.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim
index e1784491b..593bd2d56 100644
--- a/lib/pure/nativesockets.nim
+++ b/lib/pure/nativesockets.nim
@@ -392,6 +392,8 @@ when not useNimNetLite:
       myAddr: pointer
       addrLen = 0
       family = 0
+    
+    defer: freeAddrInfo(addrInfo)
 
     if addrInfo.ai_addr.sa_family.cint == nativeAfInet:
       family = nativeAfInet
@@ -404,8 +406,6 @@ when not useNimNetLite:
     else:
       raise newException(IOError, "Unknown socket family in `getHostByAddr()`")
 
-    freeAddrInfo(addrInfo)
-
     when useWinVersion:
       var s = winlean.gethostbyaddr(cast[ptr InAddr](myAddr), addrLen.cuint,
                                     cint(family))