test/drbgtest.c:907: error: NULL_DEREFERENCE
  pointer `master` last assigned on line 906 could be null and is dereferenced at line 907, column 48.
Showing all 13 steps of the trace


test/drbgtest.c:904:1: start of procedure test_rand_add()
902.    * RAND_add() is enough to reseed it.
903.    */
904. > static int test_rand_add(void)
905.   {
906.       RAND_DRBG *master = RAND_DRBG_get0_master();

test/drbgtest.c:906:5: 
904.   static int test_rand_add(void)
905.   {
906. >     RAND_DRBG *master = RAND_DRBG_get0_master();
907.       RAND_DRBG_get_entropy_fn old_get_entropy = master->get_entropy;
908.       RAND_DRBG_cleanup_entropy_fn old_cleanup_entropy = master->cleanup_entropy;

crypto/rand/drbg_lib.c:993:1: start of procedure RAND_DRBG_get0_master()
  991.    *
  992.    */
  993. > RAND_DRBG *RAND_DRBG_get0_master(void)
  994.   {
  995.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))

crypto/rand/drbg_lib.c:995:10: 
  993.   RAND_DRBG *RAND_DRBG_get0_master(void)
  994.   {
  995. >     if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
  996.           return NULL;
  997.   

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/drbg_lib.c:995:10: Condition is false
  993.   RAND_DRBG *RAND_DRBG_get0_master(void)
  994.   {
  995.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
                  ^
  996.           return NULL;
  997.   

crypto/rand/drbg_lib.c:995:10: Taking true branch
  993.   RAND_DRBG *RAND_DRBG_get0_master(void)
  994.   {
  995.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
                  ^
  996.           return NULL;
  997.   

crypto/rand/drbg_lib.c:996:9: 
  994.   {
  995.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
  996. >         return NULL;
  997.   
  998.       return master_drbg;

crypto/rand/drbg_lib.c:999:1: return from a call to RAND_DRBG_get0_master
  997.   
  998.       return master_drbg;
  999. > }
  1000.   
  1001.   /*

test/drbgtest.c:907:5: 
905.   {
906.       RAND_DRBG *master = RAND_DRBG_get0_master();
907. >     RAND_DRBG_get_entropy_fn old_get_entropy = master->get_entropy;
908.       RAND_DRBG_cleanup_entropy_fn old_cleanup_entropy = master->cleanup_entropy;
909.       int rv = 0;

static int test_rand_add(void)
{
    RAND_DRBG *master = RAND_DRBG_get0_master();
    RAND_DRBG_get_entropy_fn old_get_entropy = master->get_entropy;
    RAND_DRBG_cleanup_entropy_fn old_cleanup_entropy = master->cleanup_entropy;
    int rv = 0;
    unsigned char rand_add_buf[256];
    master->get_entropy = get_pool_entropy;
    master->cleanup_entropy = cleanup_pool_entropy;
    master->reseed_counter++;
    RAND_DRBG_uninstantiate(master);
    memset(rand_add_buf, 0xCD, sizeof(rand_add_buf));
    RAND_add(rand_add_buf, sizeof(rand_add_buf), sizeof(rand_add_buf));
    if (!TEST_true(RAND_DRBG_instantiate(master, NULL, 0)))
        goto error;
    rv = 1;
error:
    master->get_entropy = old_get_entropy;
    master->cleanup_entropy = old_cleanup_entropy;
    return rv;
}
['static int test_rand_add(void)\n{\n    RAND_DRBG *master = RAND_DRBG_get0_master();\n    RAND_DRBG_get_entropy_fn old_get_entropy = master->get_entropy;\n    RAND_DRBG_cleanup_entropy_fn old_cleanup_entropy = master->cleanup_entropy;\n    int rv = 0;\n    unsigned char rand_add_buf[256];\n    master->get_entropy = get_pool_entropy;\n    master->cleanup_entropy = cleanup_pool_entropy;\n    master->reseed_counter++;\n    RAND_DRBG_uninstantiate(master);\n    memset(rand_add_buf, 0xCD, sizeof(rand_add_buf));\n    RAND_add(rand_add_buf, sizeof(rand_add_buf), sizeof(rand_add_buf));\n    if (!TEST_true(RAND_DRBG_instantiate(master, NULL, 0)))\n        goto error;\n    rv = 1;\nerror:\n    master->get_entropy = old_get_entropy;\n    master->cleanup_entropy = old_cleanup_entropy;\n    return rv;\n}', 'RAND_DRBG *RAND_DRBG_get0_master(void)\n{\n    if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))\n        return NULL;\n    return master_drbg;\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}']