crypto/rand/drbg_rand.c:396: error: NULL_DEREFERENCE
  pointer `dctx` last assigned on line 393 could be null and is dereferenced at line 396, column 30.
Showing all 14 steps of the trace


crypto/rand/drbg_rand.c:391:1: start of procedure drbg_bytes()
389.   }
390.   
391. > static int drbg_bytes(unsigned char *out, int count)
392.   {
393.       DRBG_CTX *dctx = RAND_DRBG_get_default();

crypto/rand/drbg_rand.c:393:5: 
391.   static int drbg_bytes(unsigned char *out, int count)
392.   {
393. >     DRBG_CTX *dctx = RAND_DRBG_get_default();
394.       int ret = 0;
395.   

crypto/rand/drbg_rand.c:384:1: start of procedure RAND_DRBG_get_default()
  382.    */
  383.   
  384. > DRBG_CTX *RAND_DRBG_get_default(void)
  385.   {
  386.       if (!RUN_ONCE(&ossl_drbg_init, do_ossl_drbg_init))

crypto/rand/drbg_rand.c:386:10: 
  384.   DRBG_CTX *RAND_DRBG_get_default(void)
  385.   {
  386. >     if (!RUN_ONCE(&ossl_drbg_init, do_ossl_drbg_init))
  387.           return NULL;
  388.       return &ossl_drbg;

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_rand.c:386:10: Condition is false
  384.   DRBG_CTX *RAND_DRBG_get_default(void)
  385.   {
  386.       if (!RUN_ONCE(&ossl_drbg_init, do_ossl_drbg_init))
                  ^
  387.           return NULL;
  388.       return &ossl_drbg;

crypto/rand/drbg_rand.c:386:10: Taking true branch
  384.   DRBG_CTX *RAND_DRBG_get_default(void)
  385.   {
  386.       if (!RUN_ONCE(&ossl_drbg_init, do_ossl_drbg_init))
                  ^
  387.           return NULL;
  388.       return &ossl_drbg;

crypto/rand/drbg_rand.c:387:9: 
  385.   {
  386.       if (!RUN_ONCE(&ossl_drbg_init, do_ossl_drbg_init))
  387. >         return NULL;
  388.       return &ossl_drbg;
  389.   }

crypto/rand/drbg_rand.c:389:1: return from a call to RAND_DRBG_get_default
  387.           return NULL;
  388.       return &ossl_drbg;
  389. > }
  390.   
  391.   static int drbg_bytes(unsigned char *out, int count)

crypto/rand/drbg_rand.c:394:5: 
392.   {
393.       DRBG_CTX *dctx = RAND_DRBG_get_default();
394. >     int ret = 0;
395.   
396.       CRYPTO_THREAD_write_lock(dctx->lock);

crypto/rand/drbg_rand.c:396:5: 
394.       int ret = 0;
395.   
396. >     CRYPTO_THREAD_write_lock(dctx->lock);
397.       do {
398.           size_t rcnt;

static int drbg_bytes(unsigned char *out, int count)
{
    DRBG_CTX *dctx = RAND_DRBG_get_default();
    int ret = 0;
    CRYPTO_THREAD_write_lock(dctx->lock);
    do {
        size_t rcnt;
        if (count > (int)dctx->max_request)
            rcnt = dctx->max_request;
        else
            rcnt = count;
        ret = RAND_DRBG_generate(dctx, out, rcnt, 0, NULL, 0);
        if (!ret)
            goto err;
        out += rcnt;
        count -= rcnt;
    } while (count);
    ret = 1;
err:
    CRYPTO_THREAD_unlock(dctx->lock);
    return ret;
}
['static int drbg_bytes(unsigned char *out, int count)\n{\n    DRBG_CTX *dctx = RAND_DRBG_get_default();\n    int ret = 0;\n    CRYPTO_THREAD_write_lock(dctx->lock);\n    do {\n        size_t rcnt;\n        if (count > (int)dctx->max_request)\n            rcnt = dctx->max_request;\n        else\n            rcnt = count;\n        ret = RAND_DRBG_generate(dctx, out, rcnt, 0, NULL, 0);\n        if (!ret)\n            goto err;\n        out += rcnt;\n        count -= rcnt;\n    } while (count);\n    ret = 1;\nerr:\n    CRYPTO_THREAD_unlock(dctx->lock);\n    return ret;\n}', 'DRBG_CTX *RAND_DRBG_get_default(void)\n{\n    if (!RUN_ONCE(&ossl_drbg_init, do_ossl_drbg_init))\n        return NULL;\n    return &ossl_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}']