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


test/drbgtest.c:914:1: start of procedure test_rand_add()
912.    * RAND_add() is enough to reseed it.
913.    */
914. > static int test_rand_add(void)
915.   {
916.       RAND_DRBG *master = RAND_DRBG_get0_master();

test/drbgtest.c:916:5: 
914.   static int test_rand_add(void)
915.   {
916. >     RAND_DRBG *master = RAND_DRBG_get0_master();
917.       RAND_DRBG_get_entropy_fn old_get_entropy = master->get_entropy;
918.       RAND_DRBG_cleanup_entropy_fn old_cleanup_entropy = master->cleanup_entropy;

crypto/rand/drbg_lib.c:1002:1: start of procedure RAND_DRBG_get0_master()
  1000.    *
  1001.    */
  1002. > RAND_DRBG *RAND_DRBG_get0_master(void)
  1003.   {
  1004.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))

crypto/rand/drbg_lib.c:1004:10: 
  1002.   RAND_DRBG *RAND_DRBG_get0_master(void)
  1003.   {
  1004. >     if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
  1005.           return NULL;
  1006.   

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/drbg_lib.c:1004:10: Condition is false
  1002.   RAND_DRBG *RAND_DRBG_get0_master(void)
  1003.   {
  1004.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
                   ^
  1005.           return NULL;
  1006.   

crypto/rand/drbg_lib.c:1004:10: Taking true branch
  1002.   RAND_DRBG *RAND_DRBG_get0_master(void)
  1003.   {
  1004.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
                   ^
  1005.           return NULL;
  1006.   

crypto/rand/drbg_lib.c:1005:9: 
  1003.   {
  1004.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
  1005. >         return NULL;
  1006.   
  1007.       return master_drbg;

crypto/rand/drbg_lib.c:1008:1: return from a call to RAND_DRBG_get0_master
  1006.   
  1007.       return master_drbg;
  1008. > }
  1009.   
  1010.   /*

test/drbgtest.c:917:5: 
915.   {
916.       RAND_DRBG *master = RAND_DRBG_get0_master();
917. >     RAND_DRBG_get_entropy_fn old_get_entropy = master->get_entropy;
918.       RAND_DRBG_cleanup_entropy_fn old_cleanup_entropy = master->cleanup_entropy;
919.       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}']