[pypy-commit] pypy default: Try to be more careful about free()ing this in case something fails.

arigo noreply at buildbot.pypy.org
Mon Jan 23 15:34:54 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r51686:598e02bd0eb8
Date: 2012-01-23 15:34 +0100
http://bitbucket.org/pypy/pypy/changeset/598e02bd0eb8/

Log:	Try to be more careful about free()ing this in case something fails.

diff --git a/pypy/module/_hashlib/interp_hashlib.py b/pypy/module/_hashlib/interp_hashlib.py
--- a/pypy/module/_hashlib/interp_hashlib.py
+++ b/pypy/module/_hashlib/interp_hashlib.py
@@ -34,8 +34,12 @@
 
         ctx = lltype.malloc(ropenssl.EVP_MD_CTX.TO, flavor='raw')
         rgc.add_memory_pressure(HASH_MALLOC_SIZE + self.digest_size)
-        ropenssl.EVP_DigestInit(ctx, digest_type)
-        self.ctx = ctx
+        try:
+            ropenssl.EVP_DigestInit(ctx, digest_type)
+            self.ctx = ctx
+        except:
+            lltype.free(ctx, flavor='raw')
+            raise
 
     def __del__(self):
         # self.lock.free()


More information about the pypy-commit mailing list