From f259290e08dd68521c8f9bb1973b763f05ceac98 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 9 Feb 2009 09:57:53 -0800 Subject: [PATCH] netdev: fix segfault in lookup_netdev(). svec_find() returns SIZE_MAX, not 0, when the specified name cannot be found. Don't dereference the names array in this case. Fixes a segfault that commonly occurred when secchan was started by vswitchd. --- lib/netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/netdev.c b/lib/netdev.c index 8cf778f3..1dbc7630 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -1113,7 +1113,7 @@ static const char * lookup_netdev(const struct netdev_monitor *mon, const char *name) { size_t idx = svec_find(&mon->netdevs, name); - return idx ? mon->netdevs.names[idx] : NULL; + return idx != SIZE_MAX ? mon->netdevs.names[idx] : NULL; } static const char * -- 2.30.2