Skip to content

Commit

Permalink
Merge pull request snabbco#188 from aperezdc/fix-if-nameindex
Browse files Browse the repository at this point in the history
Close socket immediately after error in if_nametoindex()
  • Loading branch information
justincormack committed Feb 9, 2016
2 parents 96c0286 + 8915a83 commit 5f14711
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion syscall/linux/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ function util.if_nametoindex(name) -- standard function in some libc versions
local s, err = S.socket(c.AF.LOCAL, c.SOCK.STREAM, 0)
if not s then return nil, err end
local i, err = if_nametoindex(name, s)
if not i then return nil, err end
if not i then
S.close(s)
return nil, err
end
local ok, err = S.close(s)
if not ok then return nil, err end
return i
Expand Down

0 comments on commit 5f14711

Please sign in to comment.