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


test/drbgtest.c:587:1: start of procedure unhook_drbg()
585.   
586.   /* Installs the hook for the get_entropy() callback of the given drbg */
587. > static void unhook_drbg(RAND_DRBG *drbg)
588.   {
589.       HOOK_CTX *ctx = get_hook_ctx(drbg);

test/drbgtest.c:589:5: 
587.   static void unhook_drbg(RAND_DRBG *drbg)
588.   {
589. >     HOOK_CTX *ctx = get_hook_ctx(drbg);
590.   
591.       drbg->get_entropy = ctx->get_entropy;

test/drbgtest.c:552:1: start of procedure get_hook_ctx()
  550.   static HOOK_CTX master_ctx, public_ctx, private_ctx;
  551.   
  552. > static HOOK_CTX *get_hook_ctx(RAND_DRBG *drbg)
  553.   {
  554.       return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);

test/drbgtest.c:554:5: 
  552.   static HOOK_CTX *get_hook_ctx(RAND_DRBG *drbg)
  553.   {
  554. >     return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
  555.   }
  556.   

crypto/rand/drbg_lib.c:1108:1: start of procedure RAND_DRBG_get_ex_data()
    1106.   }
    1107.   
    1108. > void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx)
    1109.   {
    1110.       return CRYPTO_get_ex_data(&drbg->ex_data, idx);

crypto/rand/drbg_lib.c:1110:5: 
    1108.   void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx)
    1109.   {
    1110. >     return CRYPTO_get_ex_data(&drbg->ex_data, idx);
    1111.   }
    1112.   

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:1111:1: return from a call to RAND_DRBG_get_ex_data
    1109.   {
    1110.       return CRYPTO_get_ex_data(&drbg->ex_data, idx);
    1111. > }
    1112.   
    1113.   

test/drbgtest.c:555:1: return from a call to get_hook_ctx
  553.   {
  554.       return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
  555. > }
  556.   
  557.   /* Intercepts and counts calls to the get_entropy() callback */

test/drbgtest.c:591:5: 
589.       HOOK_CTX *ctx = get_hook_ctx(drbg);
590.   
591. >     drbg->get_entropy = ctx->get_entropy;
592.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DRBG, drbg, &drbg->ex_data);
593.   }
