Skip to content

Commit

Permalink
fix use after free
Browse files Browse the repository at this point in the history
  • Loading branch information
haoyu234 committed Oct 22, 2023
1 parent c13c485 commit 8556d86
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pure/nativesockets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit 8556d86

Please sign in to comment.