crypto/x509/x509_vfy.c:390: error: NULL_DEREFERENCE
  pointer `x` last assigned on line 389 could be null and is dereferenced by call to `X509_check_purpose()` at line 390, column 8.
Showing all 13 steps of the trace


crypto/x509/x509_vfy.c:377:1: start of procedure check_chain_purpose()
375.    */
376.   
377. > static int check_chain_purpose(X509_STORE_CTX *ctx)
378.   {
379.   #ifdef OPENSSL_NO_CHAIN_VERIFY

crypto/x509/x509_vfy.c:382:2: 
380.   	return 1;
381.   #else
382. > 	int i, ok=0;
383.   	X509 *x;
384.   	int (*cb)();

crypto/x509/x509_vfy.c:385:2: 
383.   	X509 *x;
384.   	int (*cb)();
385. > 	cb=ctx->verify_cb;
386.   	/* Check all untrusted certificates */
387.   	for (i = 0; i < ctx->last_untrusted; i++)

crypto/x509/x509_vfy.c:387:7: 
385.   	cb=ctx->verify_cb;
386.   	/* Check all untrusted certificates */
387. > 	for (i = 0; i < ctx->last_untrusted; i++)
388.   		{
389.   		x = sk_X509_value(ctx->chain, i);

crypto/x509/x509_vfy.c:387:14: Loop condition is true. Entering loop body
385.   	cb=ctx->verify_cb;
386.   	/* Check all untrusted certificates */
387.   	for (i = 0; i < ctx->last_untrusted; i++)
                    ^
388.   		{
389.   		x = sk_X509_value(ctx->chain, i);

crypto/x509/x509_vfy.c:389:3: 
387.   	for (i = 0; i < ctx->last_untrusted; i++)
388.   		{
389. > 		x = sk_X509_value(ctx->chain, i);
390.   		if (!X509_check_purpose(x, ctx->purpose, i))
391.   			{

crypto/stack/stack.c:307:1: start of procedure sk_value()
  305.   }
  306.   
  307. > char *sk_value(const STACK *st, int i)
  308.   {
  309.   	if(st == NULL) return NULL;

crypto/stack/stack.c:309:5: Taking true branch
  307.   char *sk_value(const STACK *st, int i)
  308.   {
  309.   	if(st == NULL) return NULL;
             ^
  310.   	return st->data[i];
  311.   }

crypto/stack/stack.c:309:17: 
  307.   char *sk_value(const STACK *st, int i)
  308.   {
  309. > 	if(st == NULL) return NULL;
  310.   	return st->data[i];
  311.   }

crypto/stack/stack.c:311:1: return from a call to sk_value
  309.   	if(st == NULL) return NULL;
  310.   	return st->data[i];
  311. > }
  312.   
  313.   char *sk_set(STACK *st, int i, char *value)

crypto/x509/x509_vfy.c:390:8: 
388.   		{
389.   		x = sk_X509_value(ctx->chain, i);
390. > 		if (!X509_check_purpose(x, ctx->purpose, i))
391.   			{
392.   			if (i)

crypto/x509v3/v3_purp.c:108:1: start of procedure X509_check_purpose()
  106.    * I really can't because it does recalculate hashes and do other non-const
  107.    * things. */
  108. > int X509_check_purpose(X509 *x, int id, int ca)
  109.   {
  110.   	int idx;

crypto/x509v3/v3_purp.c:112:7: 
  110.   	int idx;
  111.   	const X509_PURPOSE *pt;
  112. > 	if(!(x->ex_flags & EXFLAG_SET)) {
  113.   		CRYPTO_w_lock(CRYPTO_LOCK_X509);
  114.   		x509v3_cache_extensions(x);
