crypto/rand/rand_lib.c:413: error: NULL_DEREFERENCE
  pointer `meth` last assigned on line 387 could be null and is dereferenced at line 413, column 13.
Showing all 24 steps of the trace


crypto/rand/rand_lib.c:381:1: start of procedure RAND_poll()
379.    * configurable via the --with-rand-seed configure option.
380.    */
381. > int RAND_poll(void)
382.   {
383.       int ret = 0;

crypto/rand/rand_lib.c:383:5: 
381.   int RAND_poll(void)
382.   {
383. >     int ret = 0;
384.   
385.       RAND_POOL *pool = NULL;

crypto/rand/rand_lib.c:385:5: 
383.       int ret = 0;
384.   
385. >     RAND_POOL *pool = NULL;
386.   
387.       const RAND_METHOD *meth = RAND_get_rand_method();

crypto/rand/rand_lib.c:387:5: 
385.       RAND_POOL *pool = NULL;
386.   
387. >     const RAND_METHOD *meth = RAND_get_rand_method();
388.   
389.       if (meth == RAND_OpenSSL()) {

crypto/rand/rand_lib.c:737:1: start of procedure RAND_get_rand_method()
  735.   }
  736.   
  737. > const RAND_METHOD *RAND_get_rand_method(void)
  738.   {
  739.       const RAND_METHOD *tmp_meth = NULL;

crypto/rand/rand_lib.c:739:5: 
  737.   const RAND_METHOD *RAND_get_rand_method(void)
  738.   {
  739. >     const RAND_METHOD *tmp_meth = NULL;
  740.   
  741.       if (!RUN_ONCE(&rand_init, do_rand_init))

crypto/rand/rand_lib.c:741:10: 
  739.       const RAND_METHOD *tmp_meth = NULL;
  740.   
  741. >     if (!RUN_ONCE(&rand_init, do_rand_init))
  742.           return NULL;
  743.   

crypto/threads_pthread.c:111:1: start of procedure CRYPTO_THREAD_run_once()
    109.   }
    110.   
    111. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    112.   {
    113.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:113:9: Taking true branch
    111.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    112.   {
    113.       if (pthread_once(once, init) != 0)
                   ^
    114.           return 0;
    115.   

crypto/threads_pthread.c:114:9: 
    112.   {
    113.       if (pthread_once(once, init) != 0)
    114. >         return 0;
    115.   
    116.       return 1;

crypto/threads_pthread.c:117:1: return from a call to CRYPTO_THREAD_run_once
    115.   
    116.       return 1;
    117. > }
    118.   
    119.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/rand/rand_lib.c:741:10: Condition is false
  739.       const RAND_METHOD *tmp_meth = NULL;
  740.   
  741.       if (!RUN_ONCE(&rand_init, do_rand_init))
                  ^
  742.           return NULL;
  743.   

crypto/rand/rand_lib.c:741:10: Taking true branch
  739.       const RAND_METHOD *tmp_meth = NULL;
  740.   
  741.       if (!RUN_ONCE(&rand_init, do_rand_init))
                  ^
  742.           return NULL;
  743.   

crypto/rand/rand_lib.c:742:9: 
  740.   
  741.       if (!RUN_ONCE(&rand_init, do_rand_init))
  742. >         return NULL;
  743.   
  744.       CRYPTO_THREAD_write_lock(rand_meth_lock);

crypto/rand/rand_lib.c:765:1: return from a call to RAND_get_rand_method
  763.       CRYPTO_THREAD_unlock(rand_meth_lock);
  764.       return tmp_meth;
  765. > }
  766.   
  767.   #ifndef OPENSSL_NO_ENGINE

crypto/rand/rand_lib.c:389:9: 
387.       const RAND_METHOD *meth = RAND_get_rand_method();
388.   
389. >     if (meth == RAND_OpenSSL()) {
390.           /* fill random pool and seed the master DRBG */
391.           RAND_DRBG *drbg = RAND_DRBG_get0_master();

crypto/rand/drbg_lib.c:1227:1: start of procedure RAND_OpenSSL()
  1225.   };
  1226.   
  1227. > RAND_METHOD *RAND_OpenSSL(void)
  1228.   {
  1229.       return &rand_meth;

crypto/rand/drbg_lib.c:1229:5: 
  1227.   RAND_METHOD *RAND_OpenSSL(void)
  1228.   {
  1229. >     return &rand_meth;
  1230.   }

crypto/rand/drbg_lib.c:1230:1: return from a call to RAND_OpenSSL
  1228.   {
  1229.       return &rand_meth;
  1230. > }

crypto/rand/rand_lib.c:389:9: Taking false branch
387.       const RAND_METHOD *meth = RAND_get_rand_method();
388.   
389.       if (meth == RAND_OpenSSL()) {
               ^
390.           /* fill random pool and seed the master DRBG */
391.           RAND_DRBG *drbg = RAND_DRBG_get0_master();

crypto/rand/rand_lib.c:404:9: Skipping rand_pool_new(): empty list of specs
402.       } else {
403.           /* fill random pool and seed the current legacy RNG */
404.           pool = rand_pool_new(RAND_DRBG_STRENGTH,
               ^
405.                                (RAND_DRBG_STRENGTH + 7) / 8,
406.                                RAND_POOL_MAX_LENGTH);

crypto/rand/rand_lib.c:407:13: Taking false branch
405.                                (RAND_DRBG_STRENGTH + 7) / 8,
406.                                RAND_POOL_MAX_LENGTH);
407.           if (pool == NULL)
                   ^
408.               return 0;
409.   

crypto/rand/rand_lib.c:410:13: Taking false branch
408.               return 0;
409.   
410.           if (rand_pool_acquire_entropy(pool) == 0)
                   ^
411.               goto err;
412.   

crypto/rand/rand_lib.c:413:13: 
411.               goto err;
412.   
413. >         if (meth->add == NULL
414.               || meth->add(rand_pool_buffer(pool),
415.                            rand_pool_length(pool),

int RAND_poll(void)
{
    int ret = 0;
    RAND_POOL *pool = NULL;
    const RAND_METHOD *meth = RAND_get_rand_method();
    if (meth == RAND_OpenSSL()) {
        RAND_DRBG *drbg = RAND_DRBG_get0_master();
        if (drbg == NULL)
            return 0;
        rand_drbg_lock(drbg);
        ret = rand_drbg_restart(drbg, NULL, 0, 0);
        rand_drbg_unlock(drbg);
        return ret;
    } else {
        pool = rand_pool_new(RAND_DRBG_STRENGTH,
                             (RAND_DRBG_STRENGTH + 7) / 8,
                             RAND_POOL_MAX_LENGTH);
        if (pool == NULL)
            return 0;
        if (rand_pool_acquire_entropy(pool) == 0)
            goto err;
        if (meth->add == NULL
            || meth->add(rand_pool_buffer(pool),
                         rand_pool_length(pool),
                         (rand_pool_entropy(pool) / 8.0)) == 0)
            goto err;
        ret = 1;
    }
err:
    rand_pool_free(pool);
    return ret;
}
['int RAND_poll(void)\n{\n    int ret = 0;\n    RAND_POOL *pool = NULL;\n    const RAND_METHOD *meth = RAND_get_rand_method();\n    if (meth == RAND_OpenSSL()) {\n        RAND_DRBG *drbg = RAND_DRBG_get0_master();\n        if (drbg == NULL)\n            return 0;\n        rand_drbg_lock(drbg);\n        ret = rand_drbg_restart(drbg, NULL, 0, 0);\n        rand_drbg_unlock(drbg);\n        return ret;\n    } else {\n        pool = rand_pool_new(RAND_DRBG_STRENGTH,\n                             (RAND_DRBG_STRENGTH + 7) / 8,\n                             RAND_POOL_MAX_LENGTH);\n        if (pool == NULL)\n            return 0;\n        if (rand_pool_acquire_entropy(pool) == 0)\n            goto err;\n        if (meth->add == NULL\n            || meth->add(rand_pool_buffer(pool),\n                         rand_pool_length(pool),\n                         (rand_pool_entropy(pool) / 8.0)) == 0)\n            goto err;\n        ret = 1;\n    }\nerr:\n    rand_pool_free(pool);\n    return ret;\n}', 'const RAND_METHOD *RAND_get_rand_method(void)\n{\n    const RAND_METHOD *tmp_meth = NULL;\n    if (!RUN_ONCE(&rand_init, do_rand_init))\n        return NULL;\n    CRYPTO_THREAD_write_lock(rand_meth_lock);\n    if (default_RAND_meth == NULL) {\n#ifndef OPENSSL_NO_ENGINE\n        ENGINE *e;\n        if ((e = ENGINE_get_default_RAND()) != NULL\n                && (tmp_meth = ENGINE_get_RAND(e)) != NULL) {\n            funct_ref = e;\n            default_RAND_meth = tmp_meth;\n        } else {\n            ENGINE_finish(e);\n            default_RAND_meth = &rand_meth;\n        }\n#else\n        default_RAND_meth = &rand_meth;\n#endif\n    }\n    tmp_meth = default_RAND_meth;\n    CRYPTO_THREAD_unlock(rand_meth_lock);\n    return tmp_meth;\n}', 'int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))\n{\n    if (pthread_once(once, init) != 0)\n        return 0;\n    return 1;\n}', 'RAND_METHOD *RAND_OpenSSL(void)\n{\n    return &rand_meth;\n}']