providers/common/digests/sha2.c:62: error: NULL_DEREFERENCE
  pointer `ret` last assigned on line 60 could be null and is dereferenced at line 62, column 5.
Showing all 15 steps of the trace


providers/common/digests/sha2.c:57:1: start of procedure sha256_dupctx()
55.   }
56.   
57. > static void *sha256_dupctx(void *ctx)
58.   {
59.       SHA256_CTX *in = (SHA256_CTX *)ctx;

providers/common/digests/sha2.c:59:5: 
57.   static void *sha256_dupctx(void *ctx)
58.   {
59. >     SHA256_CTX *in = (SHA256_CTX *)ctx;
60.       SHA256_CTX *ret = OPENSSL_malloc(sizeof(*ret));
61.   

providers/common/digests/sha2.c:60:5: 
58.   {
59.       SHA256_CTX *in = (SHA256_CTX *)ctx;
60. >     SHA256_CTX *ret = OPENSSL_malloc(sizeof(*ret));
61.   
62.       *ret = *in;

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
  190.   #endif
  191.   
  192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  193.   {
  194.       void *ret = NULL;

crypto/mem.c:194:5: 
  192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  193.   {
  194. >     void *ret = NULL;
  195.   
  196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
  195.   
  196.       INCREMENT(malloc_count);
  197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  198.           return malloc_impl(num, file, line);
  199.   

crypto/mem.c:200:9: Taking false branch
  198.           return malloc_impl(num, file, line);
  199.   
  200.       if (num == 0)
                 ^
  201.           return NULL;
  202.   

crypto/mem.c:204:9: Taking true branch
  202.   
  203.       FAILTEST();
  204.       if (allow_customize) {
                 ^
  205.           /*
  206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
  208.            * allocation.
  209.            */
  210. >         allow_customize = 0;
  211.       }
  212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

crypto/mem.c:221:5: 
  219.       }
  220.   #else
  221. >     (void)(file); (void)(line);
  222.       ret = malloc(num);
  223.   #endif

crypto/mem.c:221:19: 
  219.       }
  220.   #else
  221. >     (void)(file); (void)(line);
  222.       ret = malloc(num);
  223.   #endif

crypto/mem.c:222:5: 
  220.   #else
  221.       (void)(file); (void)(line);
  222. >     ret = malloc(num);
  223.   #endif
  224.   

crypto/mem.c:225:5: 
  223.   #endif
  224.   
  225. >     return ret;
  226.   }
  227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
  224.   
  225.       return ret;
  226. > }
  227.   
  228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

providers/common/digests/sha2.c:62:5: 
60.       SHA256_CTX *ret = OPENSSL_malloc(sizeof(*ret));
61.   
62. >     *ret = *in;
63.   
64.       return ret;

static void *sha256_dupctx(void *ctx)
{
    SHA256_CTX *in = (SHA256_CTX *)ctx;
    SHA256_CTX *ret = OPENSSL_malloc(sizeof(*ret));
    *ret = *in;
    return ret;
}
['static void *sha256_dupctx(void *ctx)\n{\n    SHA256_CTX *in = (SHA256_CTX *)ctx;\n    SHA256_CTX *ret = OPENSSL_malloc(sizeof(*ret));\n    *ret = *in;\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']