From ccea54529305f0cc69e4cddc63db68ba22285d04 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Sun, 24 Jul 2022 18:56:53 +0000 Subject: [PATCH] Fix handling of bad SNMP variable type when parsing IP_* vars (#1097) AFAICT, we never associate snmp_netIpFn() with the wrong variable type, so we may be dealing with a bug in an effectively unreachable code here. 1999 commit 736eb6a correctly removed snmp_var_free() call from most refactored SNMP functions but missed snmp_netIpFn() and snmp_meshCtblFn() cases. The latter was fixed in 2000 commit d20b1cd. Detected by static analyzer Svace v3.2.1. --- src/ipcache.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ipcache.cc b/src/ipcache.cc index 62fdfbf964..f03e579a42 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1226,8 +1226,7 @@ snmp_netIpFn(variable_list * Var, snint * ErrP) default: *ErrP = SNMP_ERR_NOSUCHNAME; - snmp_var_free(Answer); - return (nullptr); + assert(!Answer); } return Answer; -- 2.47.3