test/drbgtest.c:951: error: NULL_DEREFERENCE
  pointer `master` last assigned on line 939 could be null and is dereferenced by call to `RAND_DRBG_uninstantiate()` at line 951, column 9.
Showing all 20 steps of the trace


test/drbgtest.c:937:1: start of procedure test_rand_seed()
935.    * is expected to succeed always.
936.    */
937. > static int test_rand_seed(void)
938.   {
939.       RAND_DRBG *master = RAND_DRBG_get0_master();

test/drbgtest.c:939:5: 
937.   static int test_rand_seed(void)
938.   {
939. >     RAND_DRBG *master = RAND_DRBG_get0_master();
940.       unsigned char rand_buf[256];
941.       size_t rand_buflen;

crypto/rand/drbg_lib.c:1166:1: start of procedure RAND_DRBG_get0_master()
  1164.    *
  1165.    */
  1166. > RAND_DRBG *RAND_DRBG_get0_master(void)
  1167.   {
  1168.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))

crypto/rand/drbg_lib.c:1168:10: 
  1166.   RAND_DRBG *RAND_DRBG_get0_master(void)
  1167.   {
  1168. >     if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
  1169.           return NULL;
  1170.   

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:1168:10: Condition is false
  1166.   RAND_DRBG *RAND_DRBG_get0_master(void)
  1167.   {
  1168.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
                   ^
  1169.           return NULL;
  1170.   

crypto/rand/drbg_lib.c:1168:10: Taking true branch
  1166.   RAND_DRBG *RAND_DRBG_get0_master(void)
  1167.   {
  1168.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
                   ^
  1169.           return NULL;
  1170.   

crypto/rand/drbg_lib.c:1169:9: 
  1167.   {
  1168.       if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init))
  1169. >         return NULL;
  1170.   
  1171.       return master_drbg;

crypto/rand/drbg_lib.c:1172:1: return from a call to RAND_DRBG_get0_master
  1170.   
  1171.       return master_drbg;
  1172. > }
  1173.   
  1174.   /*

test/drbgtest.c:945:5: 
943.       size_t required_seed_buflen = rand_drbg_seedlen(master);
944.   #else
945. >     size_t required_seed_buflen = 0;
946.   #endif
947.   

test/drbgtest.c:948:5: 
946.   #endif
947.   
948. >     memset(rand_buf, 0xCD, sizeof(rand_buf));
949.   
950.       for ( rand_buflen = 256 ; rand_buflen > 0 ; --rand_buflen ) {

test/drbgtest.c:950:11: 
948.       memset(rand_buf, 0xCD, sizeof(rand_buf));
949.   
950. >     for ( rand_buflen = 256 ; rand_buflen > 0 ; --rand_buflen ) {
951.           RAND_DRBG_uninstantiate(master);
952.           RAND_seed(rand_buf, rand_buflen);

test/drbgtest.c:950:31: Loop condition is true. Entering loop body
948.       memset(rand_buf, 0xCD, sizeof(rand_buf));
949.   
950.       for ( rand_buflen = 256 ; rand_buflen > 0 ; --rand_buflen ) {
                                     ^
951.           RAND_DRBG_uninstantiate(master);
952.           RAND_seed(rand_buf, rand_buflen);

test/drbgtest.c:951:9: 
949.   
950.       for ( rand_buflen = 256 ; rand_buflen > 0 ; --rand_buflen ) {
951. >         RAND_DRBG_uninstantiate(master);
952.           RAND_seed(rand_buf, rand_buflen);
953.   

crypto/rand/drbg_lib.c:439:1: start of procedure RAND_DRBG_uninstantiate()
  437.    * Returns 1 on success, 0 on failure.
  438.    */
  439. > int RAND_DRBG_uninstantiate(RAND_DRBG *drbg)
  440.   {
  441.       int index = -1, type, flags;

crypto/rand/drbg_lib.c:441:5: 
  439.   int RAND_DRBG_uninstantiate(RAND_DRBG *drbg)
  440.   {
  441. >     int index = -1, type, flags;
  442.       if (drbg->meth == NULL) {
  443.           RANDerr(RAND_F_RAND_DRBG_UNINSTANTIATE,

crypto/rand/drbg_lib.c:442:9: 
  440.   {
  441.       int index = -1, type, flags;
  442. >     if (drbg->meth == NULL) {
  443.           RANDerr(RAND_F_RAND_DRBG_UNINSTANTIATE,
  444.                   RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED);

static int test_rand_seed(void)
{
    RAND_DRBG *master = RAND_DRBG_get0_master();
    unsigned char rand_buf[256];
    size_t rand_buflen;
#ifdef OPENSSL_RAND_SEED_NONE
    size_t required_seed_buflen = rand_drbg_seedlen(master);
#else
    size_t required_seed_buflen = 0;
#endif
    memset(rand_buf, 0xCD, sizeof(rand_buf));
    for ( rand_buflen = 256 ; rand_buflen > 0 ; --rand_buflen ) {
        RAND_DRBG_uninstantiate(master);
        RAND_seed(rand_buf, rand_buflen);
        if (!TEST_int_eq(RAND_status(),
                         (rand_buflen >= required_seed_buflen)))
            return 0;
    }
    return 1;
}
['static int test_rand_seed(void)\n{\n    RAND_DRBG *master = RAND_DRBG_get0_master();\n    unsigned char rand_buf[256];\n    size_t rand_buflen;\n#ifdef OPENSSL_RAND_SEED_NONE\n    size_t required_seed_buflen = rand_drbg_seedlen(master);\n#else\n    size_t required_seed_buflen = 0;\n#endif\n    memset(rand_buf, 0xCD, sizeof(rand_buf));\n    for ( rand_buflen = 256 ; rand_buflen > 0 ; --rand_buflen ) {\n        RAND_DRBG_uninstantiate(master);\n        RAND_seed(rand_buf, rand_buflen);\n        if (!TEST_int_eq(RAND_status(),\n                         (rand_buflen >= required_seed_buflen)))\n            return 0;\n    }\n    return 1;\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}', 'int RAND_DRBG_uninstantiate(RAND_DRBG *drbg)\n{\n    int index = -1, type, flags;\n    if (drbg->meth == NULL) {\n        RANDerr(RAND_F_RAND_DRBG_UNINSTANTIATE,\n                RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED);\n        return 0;\n    }\n    drbg->meth->uninstantiate(drbg);\n    if (drbg->flags & RAND_DRBG_FLAG_MASTER)\n        index = RAND_DRBG_TYPE_MASTER;\n    else if (drbg->flags & RAND_DRBG_FLAG_PRIVATE)\n        index = RAND_DRBG_TYPE_PRIVATE;\n    else if (drbg->flags & RAND_DRBG_FLAG_PUBLIC)\n        index = RAND_DRBG_TYPE_PUBLIC;\n    if (index != -1) {\n        flags = rand_drbg_flags[index];\n        type = rand_drbg_type[index];\n    } else {\n        flags = drbg->flags;\n        type = drbg->type;\n    }\n    return RAND_DRBG_set(drbg, type, flags);\n}']