Skip to content

Commit

Permalink
Check search returned entry before trying to index key
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Agricola <[email protected]>
  • Loading branch information
Ben Agricola committed Sep 8, 2017
1 parent 707db7f commit 3be18c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/lpm/lpm4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ function LPM4:search_entry_string (ip)
return self:search_entry(ip4.parse(ip))
end
function LPM4:search (ip)
return self:search_entry(ip).key
local entry = self:search_entry(ip)
if entry then return entry.key end
return nil
end
function LPM4:search_string (str)
return self:search(ip4.parse(str))
Expand Down

0 comments on commit 3be18c8

Please sign in to comment.