Author: Stefano Rivera <[email protected]>
Branch: openssl-1.1
Changeset: r87979:7e5923a99cab
Date: 2016-10-28 15:33 -0700
http://bitbucket.org/pypy/pypy/changeset/7e5923a99cab/

Log:    Check return values

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
@@ -66,10 +66,13 @@
         self.lock = Lock(space)
 
         ctx = ropenssl.EVP_MD_CTX_new()
+        if ctx is None:
+            raise MemoryError
         rgc.add_memory_pressure(ropenssl.HASH_MALLOC_SIZE + self.digest_size)
         try:
             if copy_from:
-                ropenssl.EVP_MD_CTX_copy(ctx, copy_from)
+                if not ropenssl.EVP_MD_CTX_copy(ctx, copy_from):
+                    raise ValueError
             else:
                 ropenssl.EVP_DigestInit(ctx, digest_type)
             self.ctx = ctx
@@ -135,9 +138,12 @@
 
     def _digest(self, space):
         ctx = ropenssl.EVP_MD_CTX_new()
+        if ctx is None:
+            raise MemoryError
         try:
             with self.lock:
-                ropenssl.EVP_MD_CTX_copy(ctx, self.ctx)
+                if not ropenssl.EVP_MD_CTX_copy(ctx, self.ctx):
+                    raise ValueError
             digest_size = self.digest_size
             with rffi.scoped_alloc_buffer(digest_size) as buf:
                 ropenssl.EVP_DigestFinal(ctx, buf.raw, None)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to