engine_md_copy: check for NULL after allocating to_md->HashBuffer
authorJonas Maebe <jonas.maebe@elis.ugent.be>
Sun, 8 Dec 2013 21:49:19 +0000 (22:49 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Sun, 17 Aug 2014 16:56:44 +0000 (18:56 +0200)
Signed-off-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
demos/engines/zencod/hw_zencod.c

index 4234b93..9ad7252 100644 (file)
@@ -1507,6 +1507,8 @@ static int engine_md_copy ( EVP_MD_CTX *to, const EVP_MD_CTX *from )
        ZEN_MD_DATA *to_md = (ZEN_MD_DATA *) to->md_data ;
 
        to_md->HashBuffer = OPENSSL_malloc ( from_md->HashBufferSize ) ;
        ZEN_MD_DATA *to_md = (ZEN_MD_DATA *) to->md_data ;
 
        to_md->HashBuffer = OPENSSL_malloc ( from_md->HashBufferSize ) ;
+       if (to_md->HashBuffer == NULL)
+               return 0;
        memcpy ( to_md->HashBuffer, from_md->HashBuffer, from_md->HashBufferSize ) ;
 
        return 1;
        memcpy ( to_md->HashBuffer, from_md->HashBuffer, from_md->HashBufferSize ) ;
 
        return 1;