I adapted the previous patch to work regardless on the value of verbose. Also bug 2823 is about the get() function, but the patch is for getnext(). Both functions have the issue and this patch covers both of them.
diff --git a/python/netsnmp/client_intf.c b/python/netsnmp/client_intf.c
index 2adf20836..2b21fed50 100644
--- a/python/netsnmp/client_intf.c
+++ b/python/netsnmp/client_intf.c
@@ -1341,6 +1341,13 @@ netsnmp_get(PyObject *self, PyObject *args)
if (varlist) {
PyObject *varlist_iter = PyObject_GetIter(varlist);
+ if (varlist_iter == NULL) {
+ if (verbose) {
+ printf("error: can't get iterator for varlist");
+ }
+ snmp_free_pdu(pdu);
+ goto done;
+ }
while (varlist_iter && (varbind = PyIter_Next(varlist_iter))) {
if (py_netsnmp_attr_string(varbind, "tag", &tag, NULL) < 0 ||
@@ -1559,6 +1566,13 @@ netsnmp_getnext(PyObject *self, PyObject *args)
if (varlist) {
PyObject *varlist_iter = PyObject_GetIter(varlist);
+ if (varlist_iter == NULL) {
+ if (verbose) {
+ printf("error: can't get iterator for varlist");
+ }
+ snmp_free_pdu(pdu);
+ goto done;
+ }
while (varlist_iter && (varbind = PyIter_Next(varlist_iter))) {
if (py_netsnmp_attr_string(varbind, "tag", &tag, NULL) < 0 ||
If you are using a Net-SNMP version older than v5.7, please upgrade to v5.7.
The patch was against the current HEAD when I made it.
Just tested, I can confirm that this bug is still present in the current HEAD.