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


crypto/rand/rand_lib.c:394:1: start of procedure RAND_poll()
392.    * configurable via the --with-rand-seed configure option.
393.    */
394. > int RAND_poll(void)
395.   {
396.       int ret = 0;

crypto/rand/rand_lib.c:396:5: 
394.   int RAND_poll(void)
395.   {
396. >     int ret = 0;
397.   
398.       RAND_POOL *pool = NULL;

crypto/rand/rand_lib.c:398:5: 
396.       int ret = 0;
397.   
398. >     RAND_POOL *pool = NULL;
399.   
400.       const RAND_METHOD *meth = RAND_get_rand_method();

crypto/rand/rand_lib.c:400:5: 
398.       RAND_POOL *pool = NULL;
399.   
400. >     const RAND_METHOD *meth = RAND_get_rand_method();
401.   
402.       if (meth == RAND_OpenSSL()) {

crypto/rand/rand_lib.c:710:1: start of procedure RAND_get_rand_method()
  708.   }
  709.   
  710. > const RAND_METHOD *RAND_get_rand_method(void)
  711.   {
  712.       const RAND_METHOD *tmp_meth = NULL;

crypto/rand/rand_lib.c:712:5: 
  710.   const RAND_METHOD *RAND_get_rand_method(void)
  711.   {
  712. >     const RAND_METHOD *tmp_meth = NULL;
  713.   
  714.       if (!RUN_ONCE(&rand_init, do_rand_init))

crypto/rand/rand_lib.c:714:10: 
  712.       const RAND_METHOD *tmp_meth = NULL;
  713.   
  714. >     if (!RUN_ONCE(&rand_init, do_rand_init))
  715.           return NULL;
  716.   

crypto/threads_pthread.c:105:1: start of procedure CRYPTO_THREAD_run_once()
    103.   }
    104.   
    105. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    106.   {
    107.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:107:9: Taking true branch
    105.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    106.   {
    107.       if (pthread_once(once, init) != 0)
                   ^
    108.           return 0;
    109.   

crypto/threads_pthread.c:108:9: 
    106.   {
    107.       if (pthread_once(once, init) != 0)
    108. >         return 0;
    109.   
    110.       return 1;

crypto/threads_pthread.c:111:1: return from a call to CRYPTO_THREAD_run_once
    109.   
    110.       return 1;
    111. > }
    112.   
    113.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/rand/rand_lib.c:714:10: Condition is false
  712.       const RAND_METHOD *tmp_meth = NULL;
  713.   
  714.       if (!RUN_ONCE(&rand_init, do_rand_init))
                  ^
  715.           return NULL;
  716.   

crypto/rand/rand_lib.c:714:10: Taking true branch
  712.       const RAND_METHOD *tmp_meth = NULL;
  713.   
  714.       if (!RUN_ONCE(&rand_init, do_rand_init))
                  ^
  715.           return NULL;
  716.   

crypto/rand/rand_lib.c:715:9: 
  713.   
  714.       if (!RUN_ONCE(&rand_init, do_rand_init))
  715. >         return NULL;
  716.   
  717.       CRYPTO_THREAD_write_lock(rand_meth_lock);

crypto/rand/rand_lib.c:738:1: return from a call to RAND_get_rand_method
  736.       CRYPTO_THREAD_unlock(rand_meth_lock);
  737.       return tmp_meth;
  738. > }
  739.   
  740.   #ifndef OPENSSL_NO_ENGINE

crypto/rand/rand_lib.c:402:9: 
400.       const RAND_METHOD *meth = RAND_get_rand_method();
401.   
402. >     if (meth == RAND_OpenSSL()) {
403.           /* fill random pool and seed the master DRBG */
404.           RAND_DRBG *drbg = RAND_DRBG_get0_master();

crypto/rand/drbg_lib.c:890:1: start of procedure RAND_OpenSSL()
  888.   };
  889.   
  890. > RAND_METHOD *RAND_OpenSSL(void)
  891.   {
  892.       return &rand_meth;

crypto/rand/drbg_lib.c:892:5: 
  890.   RAND_METHOD *RAND_OpenSSL(void)
  891.   {
  892. >     return &rand_meth;
  893.   }

crypto/rand/drbg_lib.c:893:1: return from a call to RAND_OpenSSL
  891.   {
  892.       return &rand_meth;
  893. > }

crypto/rand/rand_lib.c:402:9: Taking false branch
400.       const RAND_METHOD *meth = RAND_get_rand_method();
401.   
402.       if (meth == RAND_OpenSSL()) {
               ^
403.           /* fill random pool and seed the master DRBG */
404.           RAND_DRBG *drbg = RAND_DRBG_get0_master();

crypto/rand/rand_lib.c:417:9: Skipping RAND_POOL_new(): empty list of specs
415.       } else {
416.           /* fill random pool and seed the current legacy RNG */
417.           pool = RAND_POOL_new(RAND_DRBG_STRENGTH,
               ^
418.                                RAND_DRBG_STRENGTH / 8,
419.                                DRBG_MINMAX_FACTOR * (RAND_DRBG_STRENGTH / 8));

crypto/rand/rand_lib.c:420:13: Taking false branch
418.                                RAND_DRBG_STRENGTH / 8,
419.                                DRBG_MINMAX_FACTOR * (RAND_DRBG_STRENGTH / 8));
420.           if (pool == NULL)
                   ^
421.               return 0;
422.   

crypto/rand/rand_lib.c:423:13: Taking false branch
421.               return 0;
422.   
423.           if (RAND_POOL_acquire_entropy(pool) == 0)
                   ^
424.               goto err;
425.   

crypto/rand/rand_lib.c:426:13: 
424.               goto err;
425.   
426. >         if (meth->add == NULL
427.               || meth->add(RAND_POOL_buffer(pool),
428.                            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;
        CRYPTO_THREAD_write_lock(drbg->lock);
        ret = rand_drbg_restart(drbg, NULL, 0, 0);
        CRYPTO_THREAD_unlock(drbg->lock);
        return ret;
    } else {
        pool = RAND_POOL_new(RAND_DRBG_STRENGTH,
                             RAND_DRBG_STRENGTH / 8,
                             DRBG_MINMAX_FACTOR * (RAND_DRBG_STRENGTH / 8));
        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        CRYPTO_THREAD_write_lock(drbg->lock);\n        ret = rand_drbg_restart(drbg, NULL, 0, 0);\n        CRYPTO_THREAD_unlock(drbg->lock);\n        return ret;\n    } else {\n        pool = RAND_POOL_new(RAND_DRBG_STRENGTH,\n                             RAND_DRBG_STRENGTH / 8,\n                             DRBG_MINMAX_FACTOR * (RAND_DRBG_STRENGTH / 8));\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}']