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


crypto/rand/rand_lib.c:412:1: start of procedure RAND_poll()
410.    * configurable via the --with-rand-seed configure option.
411.    */
412. > int RAND_poll(void)
413.   {
414.       int ret = 0;

crypto/rand/rand_lib.c:414:5: 
412.   int RAND_poll(void)
413.   {
414. >     int ret = 0;
415.   
416.       RAND_POOL *pool = NULL;

crypto/rand/rand_lib.c:416:5: 
414.       int ret = 0;
415.   
416. >     RAND_POOL *pool = NULL;
417.   
418.       const RAND_METHOD *meth = RAND_get_rand_method();

crypto/rand/rand_lib.c:418:5: 
416.       RAND_POOL *pool = NULL;
417.   
418. >     const RAND_METHOD *meth = RAND_get_rand_method();
419.   
420.       if (meth == RAND_OpenSSL()) {

crypto/rand/rand_lib.c:728:1: start of procedure RAND_get_rand_method()
  726.   }
  727.   
  728. > const RAND_METHOD *RAND_get_rand_method(void)
  729.   {
  730.       const RAND_METHOD *tmp_meth = NULL;

crypto/rand/rand_lib.c:730:5: 
  728.   const RAND_METHOD *RAND_get_rand_method(void)
  729.   {
  730. >     const RAND_METHOD *tmp_meth = NULL;
  731.   
  732.       if (!RUN_ONCE(&rand_init, do_rand_init))

crypto/rand/rand_lib.c:732:10: 
  730.       const RAND_METHOD *tmp_meth = NULL;
  731.   
  732. >     if (!RUN_ONCE(&rand_init, do_rand_init))
  733.           return NULL;
  734.   

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:732:10: Condition is false
  730.       const RAND_METHOD *tmp_meth = NULL;
  731.   
  732.       if (!RUN_ONCE(&rand_init, do_rand_init))
                  ^
  733.           return NULL;
  734.   

crypto/rand/rand_lib.c:732:10: Taking true branch
  730.       const RAND_METHOD *tmp_meth = NULL;
  731.   
  732.       if (!RUN_ONCE(&rand_init, do_rand_init))
                  ^
  733.           return NULL;
  734.   

crypto/rand/rand_lib.c:733:9: 
  731.   
  732.       if (!RUN_ONCE(&rand_init, do_rand_init))
  733. >         return NULL;
  734.   
  735.       CRYPTO_THREAD_write_lock(rand_meth_lock);

crypto/rand/rand_lib.c:756:1: return from a call to RAND_get_rand_method
  754.       CRYPTO_THREAD_unlock(rand_meth_lock);
  755.       return tmp_meth;
  756. > }
  757.   
  758.   #ifndef OPENSSL_NO_ENGINE

crypto/rand/rand_lib.c:420:9: 
418.       const RAND_METHOD *meth = RAND_get_rand_method();
419.   
420. >     if (meth == RAND_OpenSSL()) {
421.           /* fill random pool and seed the master DRBG */
422.           RAND_DRBG *drbg = RAND_DRBG_get0_master();

crypto/rand/drbg_lib.c:1072:1: start of procedure RAND_OpenSSL()
  1070.   };
  1071.   
  1072. > RAND_METHOD *RAND_OpenSSL(void)
  1073.   {
  1074.       return &rand_meth;

crypto/rand/drbg_lib.c:1074:5: 
  1072.   RAND_METHOD *RAND_OpenSSL(void)
  1073.   {
  1074. >     return &rand_meth;
  1075.   }

crypto/rand/drbg_lib.c:1075:1: return from a call to RAND_OpenSSL
  1073.   {
  1074.       return &rand_meth;
  1075. > }

crypto/rand/rand_lib.c:420:9: Taking false branch
418.       const RAND_METHOD *meth = RAND_get_rand_method();
419.   
420.       if (meth == RAND_OpenSSL()) {
               ^
421.           /* fill random pool and seed the master DRBG */
422.           RAND_DRBG *drbg = RAND_DRBG_get0_master();

crypto/rand/rand_lib.c:435:9: Skipping rand_pool_new(): empty list of specs
433.       } else {
434.           /* fill random pool and seed the current legacy RNG */
435.           pool = rand_pool_new(RAND_DRBG_STRENGTH,
               ^
436.                                RAND_DRBG_STRENGTH / 8,
437.                                DRBG_MINMAX_FACTOR * (RAND_DRBG_STRENGTH / 8));

crypto/rand/rand_lib.c:438:13: Taking false branch
436.                                RAND_DRBG_STRENGTH / 8,
437.                                DRBG_MINMAX_FACTOR * (RAND_DRBG_STRENGTH / 8));
438.           if (pool == NULL)
                   ^
439.               return 0;
440.   

crypto/rand/rand_lib.c:441:13: Taking false branch
439.               return 0;
440.   
441.           if (rand_pool_acquire_entropy(pool) == 0)
                   ^
442.               goto err;
443.   

crypto/rand/rand_lib.c:444:13: 
442.               goto err;
443.   
444. >         if (meth->add == NULL
445.               || meth->add(rand_pool_buffer(pool),
446.                            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 / 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        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 / 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}']