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


crypto/x509/x509_vfy.c:329:1: start of procedure check_chain_purpose()
327.    */
328.   
329. > static int check_chain_purpose(X509_STORE_CTX *ctx)
330.   {
331.   #ifdef NO_CHAIN_VERIFY

crypto/x509/x509_vfy.c:334:2: 
332.   	return 1;
333.   #else
334. > 	int i, ok=0;
335.   	X509 *x;
336.   	int (*cb)();

crypto/x509/x509_vfy.c:337:2: 
335.   	X509 *x;
336.   	int (*cb)();
337. > 	cb=ctx->ctx->verify_cb;
338.   	if (cb == NULL) cb=null_callback;
339.   	/* Check all untrusted certificates */

crypto/x509/x509_vfy.c:338:6: Taking false branch
336.   	int (*cb)();
337.   	cb=ctx->ctx->verify_cb;
338.   	if (cb == NULL) cb=null_callback;
            ^
339.   	/* Check all untrusted certificates */
340.   	for(i = 0; i < ctx->last_untrusted; i++) {

crypto/x509/x509_vfy.c:340:6: 
338.   	if (cb == NULL) cb=null_callback;
339.   	/* Check all untrusted certificates */
340. > 	for(i = 0; i < ctx->last_untrusted; i++) {
341.   		x = sk_X509_value(ctx->chain, i);
342.   		if(!X509_check_purpose(x, ctx->purpose, i)) {

crypto/x509/x509_vfy.c:340:13: Loop condition is true. Entering loop body
338.   	if (cb == NULL) cb=null_callback;
339.   	/* Check all untrusted certificates */
340.   	for(i = 0; i < ctx->last_untrusted; i++) {
                   ^
341.   		x = sk_X509_value(ctx->chain, i);
342.   		if(!X509_check_purpose(x, ctx->purpose, i)) {

crypto/x509/x509_vfy.c:341:3: 
339.   	/* Check all untrusted certificates */
340.   	for(i = 0; i < ctx->last_untrusted; i++) {
341. > 		x = sk_X509_value(ctx->chain, i);
342.   		if(!X509_check_purpose(x, ctx->purpose, i)) {
343.   			if(i) ctx->error = X509_V_ERR_INVALID_CA;

crypto/x509/x509_vfy.c:786:1: start of procedure sk_X509_value()
  784.   
  785.   
  786. > IMPLEMENT_STACK_OF(X509)
  787.   IMPLEMENT_ASN1_SET_OF(X509)
  788.   

crypto/stack/stack.c:289:1: start of procedure sk_value()
    287.   }
    288.   
    289. > char *sk_value(STACK *st, int i)
    290.   {
    291.   	if(st == NULL) return NULL;

crypto/stack/stack.c:291:5: Taking true branch
    289.   char *sk_value(STACK *st, int i)
    290.   {
    291.   	if(st == NULL) return NULL;
               ^
    292.   	return st->data[i];
    293.   }

crypto/stack/stack.c:291:17: 
    289.   char *sk_value(STACK *st, int i)
    290.   {
    291. > 	if(st == NULL) return NULL;
    292.   	return st->data[i];
    293.   }

crypto/stack/stack.c:293:1: return from a call to sk_value
    291.   	if(st == NULL) return NULL;
    292.   	return st->data[i];
    293. > }
    294.   
    295.   char *sk_set(STACK *st, int i, char *value)

crypto/x509/x509_vfy.c:786:1: return from a call to sk_X509_value
  784.   
  785.   
  786. > IMPLEMENT_STACK_OF(X509)
  787.   IMPLEMENT_ASN1_SET_OF(X509)
  788.   

crypto/x509/x509_vfy.c:342:7: 
340.   	for(i = 0; i < ctx->last_untrusted; i++) {
341.   		x = sk_X509_value(ctx->chain, i);
342. > 		if(!X509_check_purpose(x, ctx->purpose, i)) {
343.   			if(i) ctx->error = X509_V_ERR_INVALID_CA;
344.   			else ctx->error = X509_V_ERR_INVALID_PURPOSE;

crypto/x509v3/v3_purp.c:98:1: start of procedure X509_check_purpose()
  96.   }
  97.   
  98. > int X509_check_purpose(X509 *x, int id, int ca)
  99.   {
  100.   	int idx;

crypto/x509v3/v3_purp.c:102:7: 
  100.   	int idx;
  101.   	X509_PURPOSE *pt;
  102. > 	if(!(x->ex_flags & EXFLAG_SET)) {
  103.   		CRYPTO_w_lock(CRYPTO_LOCK_X509);
  104.   		x509v3_cache_extensions(x);
