I was thinking that the OP wanted a test failure

Where did you glean that idea from? The OP has obviously reduced a larger piece of code to a simple test case to demonstrate a really bizarre issue. Assuming it runs as advertised, the code does just what the OP wants. The question is: "Why?".

I tried reversing the sense of the test to get around the freed value warning.

What freed value warning? The OP used a die statement to show the puzzling result the code produces, but that is not an error or warning, just one of the ways the result could have been shown.

How would you handle it?

I looked at the code. Determined I hadn't the SNMP module installed and on Windows that looked like more work than I could be bothered with to install. I couldn't verify the result so I left the question for someone else to answer. dave_the_m's answer seems most likely correct, although I'd have pointed the finger at the more general "corrupting memory" answer.

If you are unsure of your understanding of a question you should either ask a follow up question (if the OP's question seems unclear) or don't answer if it is an area you are unfamiliar with and can't be bothered researching.

True laziness is hard work

In reply to Re^4: Something is leaking by GrandFather
in thread Something is leaking by mogul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.