]> granicus.if.org Git - python/commit
Fix two memory leaks in socket.ssl().
authorJeremy Hylton <jeremy@alum.mit.edu>
Wed, 10 Oct 2001 03:19:39 +0000 (03:19 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Wed, 10 Oct 2001 03:19:39 +0000 (03:19 +0000)
commitf86d63e4f04f368450f5a4e9dd3dd6c282c43bf1
treed7311c0b8dc8a95722b618c6dd07a1325aca1fa4
parent0407aeae01e38098a8dfa6fec4a04d254f8b6517
Fix two memory leaks in socket.ssl().

XXX [1] These changes aren't tested very thoroughly, because regrtest
doesn't do any SSL tests.  I've done some trivial tests on my own, but
don't really know how to use the key and cert files.  In one case, an
SSL-level error causes Python to dump core.  I'll get the fixed in the
next round of changes.

XXX [2] The checkin removes the x_attr member of the SSLObject struct.
I'm not sure if this is kosher for backwards compatibility at the
binary level.  Perhaps its safer to keep the member but keep it
assigned to NULL.

And the leaks?

newSSLObject() called PyDict_New(), stored the result in x_attr
without checking it, and later stored NULL in x_attr without doing
anything to the dict.  So the dict always leaks.  There is no further
reference to x_attr, so I just removed it completely.

The error cases in newSSLObject() passed the return value of
PyString_FromString() directly to PyErr_SetObject().
PyErr_SetObject() expects a borrowed reference, so the string leaked.
Modules/socketmodule.c