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


test/drbgtest.c:521:1: start of procedure get_entropy_hook()
519.   
520.   /* Intercepts and counts calls to the get_entropy() callback */
521. > static size_t get_entropy_hook(RAND_DRBG *drbg, unsigned char **pout,
522.                                 int entropy, size_t min_len, size_t max_len,
523.                                 int prediction_resistance)

test/drbgtest.c:526:5: 
524.   {
525.       size_t ret;
526. >     HOOK_CTX *ctx = get_hook_ctx(drbg);
527.   
528.       if (ctx->fail != 0)

test/drbgtest.c:515:1: start of procedure get_hook_ctx()
  513.   static HOOK_CTX master_ctx, public_ctx, private_ctx;
  514.   
  515. > static HOOK_CTX *get_hook_ctx(RAND_DRBG *drbg)
  516.   {
  517.       return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);

test/drbgtest.c:517:5: 
  515.   static HOOK_CTX *get_hook_ctx(RAND_DRBG *drbg)
  516.   {
  517. >     return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
  518.   }
  519.   

crypto/rand/drbg_lib.c:911:1: start of procedure RAND_DRBG_get_ex_data()
    909.   }
    910.   
    911. > void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx)
    912.   {
    913.       return CRYPTO_get_ex_data(&drbg->ex_data, idx);

crypto/rand/drbg_lib.c:913:5: 
    911.   void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx)
    912.   {
    913. >     return CRYPTO_get_ex_data(&drbg->ex_data, idx);
    914.   }
    915.   

crypto/ex_data.c:394:1: start of procedure CRYPTO_get_ex_data()
      392.    * particular index in the class used by this variable
      393.    */
      394. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
      395.   {
      396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:396:9: Taking true branch
      394.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
      395.   {
      396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                     ^
      397.           return NULL;
      398.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:397:9: 
      395.   {
      396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
      397. >         return NULL;
      398.       return sk_void_value(ad->sk, idx);
      399.   }

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

crypto/rand/drbg_lib.c:914:1: return from a call to RAND_DRBG_get_ex_data
    912.   {
    913.       return CRYPTO_get_ex_data(&drbg->ex_data, idx);
    914. > }
    915.   
    916.   

test/drbgtest.c:518:1: return from a call to get_hook_ctx
  516.   {
  517.       return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
  518. > }
  519.   
  520.   /* Intercepts and counts calls to the get_entropy() callback */

test/drbgtest.c:528:9: 
526.       HOOK_CTX *ctx = get_hook_ctx(drbg);
527.   
528. >     if (ctx->fail != 0)
529.           return 0;
530.   

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