test/drbgtest.c:558: error: NULL_DEREFERENCE
  pointer `ctx` last assigned on line 556 could be null and is dereferenced at line 558, column 9.
Showing all 13 steps of the trace


test/drbgtest.c:551:1: start of procedure get_entropy_hook()
549.   
550.   /* Intercepts and counts calls to the get_entropy() callback */
551. > static size_t get_entropy_hook(RAND_DRBG *drbg, unsigned char **pout,
552.                                 int entropy, size_t min_len, size_t max_len,
553.                                 int prediction_resistance)

test/drbgtest.c:556:5: 
554.   {
555.       size_t ret;
556. >     HOOK_CTX *ctx = get_hook_ctx(drbg);
557.   
558.       if (ctx->fail != 0)

test/drbgtest.c:545:1: start of procedure get_hook_ctx()
  543.   static HOOK_CTX master_ctx, public_ctx, private_ctx;
  544.   
  545. > static HOOK_CTX *get_hook_ctx(RAND_DRBG *drbg)
  546.   {
  547.       return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);

test/drbgtest.c:547:5: 
  545.   static HOOK_CTX *get_hook_ctx(RAND_DRBG *drbg)
  546.   {
  547. >     return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
  548.   }
  549.   

crypto/rand/drbg_lib.c:929:1: start of procedure RAND_DRBG_get_ex_data()
    927.   }
    928.   
    929. > void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx)
    930.   {
    931.       return CRYPTO_get_ex_data(&drbg->ex_data, idx);

crypto/rand/drbg_lib.c:931:5: 
    929.   void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx)
    930.   {
    931. >     return CRYPTO_get_ex_data(&drbg->ex_data, idx);
    932.   }
    933.   

crypto/ex_data.c:458:1: start of procedure CRYPTO_get_ex_data()
      456.    * particular index in the class used by this variable
      457.    */
      458. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
      459.   {
      460.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:460:9: Taking true branch
      458.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
      459.   {
      460.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                     ^
      461.           return NULL;
      462.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:461:9: 
      459.   {
      460.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
      461. >         return NULL;
      462.       return sk_void_value(ad->sk, idx);
      463.   }

crypto/ex_data.c:463:1: return from a call to CRYPTO_get_ex_data
      461.           return NULL;
      462.       return sk_void_value(ad->sk, idx);
      463. > }
      464.   
      465.   OPENSSL_CTX *crypto_ex_data_get_openssl_ctx(const CRYPTO_EX_DATA *ad)

crypto/rand/drbg_lib.c:932:1: return from a call to RAND_DRBG_get_ex_data
    930.   {
    931.       return CRYPTO_get_ex_data(&drbg->ex_data, idx);
    932. > }
    933.   
    934.   

test/drbgtest.c:548:1: return from a call to get_hook_ctx
  546.   {
  547.       return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
  548. > }
  549.   
  550.   /* Intercepts and counts calls to the get_entropy() callback */

test/drbgtest.c:558:9: 
556.       HOOK_CTX *ctx = get_hook_ctx(drbg);
557.   
558. >     if (ctx->fail != 0)
559.           return 0;
560.   

static size_t get_entropy_hook(RAND_DRBG *drbg, unsigned char **pout,
                              int entropy, size_t min_len, size_t max_len,
                              int prediction_resistance)
{
    size_t ret;
    HOOK_CTX *ctx = get_hook_ctx(drbg);
    if (ctx->fail != 0)
        return 0;
    ret = ctx->get_entropy(drbg, pout, entropy, min_len, max_len,
                           prediction_resistance);
    if (ret != 0)
        ctx->reseed_count++;
    return ret;
}
['static size_t get_entropy_hook(RAND_DRBG *drbg, unsigned char **pout,\n                              int entropy, size_t min_len, size_t max_len,\n                              int prediction_resistance)\n{\n    size_t ret;\n    HOOK_CTX *ctx = get_hook_ctx(drbg);\n    if (ctx->fail != 0)\n        return 0;\n    ret = ctx->get_entropy(drbg, pout, entropy, min_len, max_len,\n                           prediction_resistance);\n    if (ret != 0)\n        ctx->reseed_count++;\n    return ret;\n}', 'static HOOK_CTX *get_hook_ctx(RAND_DRBG *drbg)\n{\n    return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);\n}', 'void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx)\n{\n    return CRYPTO_get_ex_data(&drbg->ex_data, idx);\n}', 'void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)\n{\n    if (ad->sk == NULL || idx >= sk_void_num(ad->sk))\n        return NULL;\n    return sk_void_value(ad->sk, idx);\n}']