Description: Perl: Do not crash on resend callbacks.
 Do not act on NETSNMP_CALLBACK_OP_RESEND messages, as they are not final
 (the callback assumes that we can free the callback struct and generally
 mutate it freely without ever seeing it again, causing double-frees on
 resends).
 Updated in commit 3b4860cfcd68f47d88be8c6a14ec2203f0d04000.patch
Author: Steinar H. Gunderson" <sgunderson@bigfoot.com>
Author: Sebastian Bugge <sbugge@proton.me>
Bug: https://github.com/net-snmp/net-snmp/issues/955
Bug-Debian: https://bugs.debian.org/1152875
Applied-Upstream: https://github.com/net-snmp/net-snmp/commit/cf5d7defd20
Reviewed-by: Craig Small <csmall@debian.org>
Last-Update: 2026-11-29
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/perl/SNMP/SNMP.xs
+++ b/perl/SNMP/SNMP.xs
@@ -1147,6 +1147,17 @@
    return(status);
 }
 
+/*
+ * NETSNMP_CALLBACK_OP_RESEND only reports that a request was
+ * retransmitted. The request stays outstanding and the
+ * callback is invoked again later with its final result.
+ */
+static int
+__is_final_callback_op(int op)
+{
+   return op != NETSNMP_CALLBACK_OP_RESEND;
+}
+
 static int
 __snmp_xs_cb(int op, netsnmp_session *ss, int reqid, netsnmp_pdu *pdu,
              void *cb_data)
@@ -1182,6 +1193,9 @@
   SV **err_num_svp = hv_fetch((HV*)SvRV(sess_ref), "ErrorNum", 8, 1);
   SV **err_ind_svp = hv_fetch((HV*)SvRV(sess_ref), "ErrorInd", 8, 1);
 
+  if (!__is_final_callback_op(op))
+    return 1;
+
   ENTER;
   SAVETMPS;
 
@@ -1616,6 +1630,9 @@
 
    context = (walk_context *)context_ptr;
 
+   if (!__is_final_callback_op(op))
+      return 1;
+
    /* Make certain this is a valid context pointer.  This pdu may
    ** have been retransmitted after the bulkwalk was completed
    ** (and the context was destroyed).  If so, just return.
