Skip to content

Fix memory ownership and allocation handling - #21

Merged
bluecmd merged 1 commit into
bluecmd:masterfrom
SoundGoof:fix/walk-memory-safety
Jul 23, 2026
Merged

Fix memory ownership and allocation handling#21
bluecmd merged 1 commit into
bluecmd:masterfrom
SoundGoof:fix/walk-memory-safety

Conversation

@SoundGoof

Copy link
Copy Markdown
Collaborator

Summary

Fix memory ownership and allocation handling in netsnmp_walk().

The system-test workflow introduced in #19 exposed memory leaks under Valgrind and a heap-use-after-free under AddressSanitizer. This change:

  • Removes access to a request PDU after Net-SNMP has freed it.
  • Removes a duplicate OID allocation.
  • Frees the final GETNEXT PDU when it will not be sent.
  • Checks PDU and OID-array allocations.
  • Safely cleans up partially completed allocations.
  • Propagates allocation failures as Python MemoryError.

Testing

Executed the complete SNMP system-test suite in Podman:

  • ASan/UBSan: 31 tests passed with no sanitizer errors.
  • Valgrind: 31 tests passed with 0 errors.
  • Valgrind reported 0 bytes definitely, indirectly, or possibly lost.
  • GCC coverage job passed.

@SoundGoof
SoundGoof requested a review from bluecmd July 23, 2026 16:59
@bluecmd
bluecmd merged commit 748bce1 into bluecmd:master Jul 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants