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


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

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

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

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

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:424:1: start of procedure CRYPTO_get_ex_data()
      422.    * particular index in the class used by this variable
      423.    */
      424. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
      425.   {
      426.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:426:9: Taking true branch
      424.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
      425.   {
      426.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                     ^
      427.           return NULL;
      428.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:427:9: 
      425.   {
      426.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
      427. >         return NULL;
      428.       return sk_void_value(ad->sk, idx);
      429.   }

crypto/ex_data.c:429:1: return from a call to CRYPTO_get_ex_data
      427.           return NULL;
      428.       return sk_void_value(ad->sk, idx);
      429. > }

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:545:1: return from a call to get_hook_ctx
  543.   {
  544.       return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
  545. > }
  546.   
  547.   /* Intercepts and counts calls to the get_entropy() callback */

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

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}']