Hi list,

I noticed that snmp_sess_synch_response() *sometimes* (not always) frees
the "netsnmp_pdu *pdu" argument passed to it when returning STAT_ERROR.
For example:

  snmp_sess_session() == NULL -> pdu is not freed
  snmp_sess_send() == 0 -> pdu is freed

The caller therefore has to chose between risk leaking memory and risk a
double-free. I assume that given these choices, users opt for the
inconvenient leak over a double free.

Would you accept a patch that make the behavior deterministic (from the
POV of the caller)? I see the following options:

* If the return value is STAT_ERROR, *always* free the "pdu" argument.
  This is likely the less intrusive change, since callers must already
  assume that this is what happens.
-- OR --
* Introduce a new error code. The callers already expect that the
  argument has been freed when they get a STAT_ERROR, so returning
  SNMPERR_GENERR in cases where pdu is *not* freed might be a reasonable
  way forward.

Best regards,
—octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x0C705A15
http://octo.it/

Attachment: signature.asc
Description: Digital signature

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to