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


crypto/x509/x509_vfy.c:162:1: start of procedure X509_verify_cert()
160.   	}
161.   
162. > int X509_verify_cert(X509_STORE_CTX *ctx)
163.   	{
164.   	X509 *x,*xtmp,*chain_ss=NULL;

crypto/x509/x509_vfy.c:164:2: 
162.   int X509_verify_cert(X509_STORE_CTX *ctx)
163.   	{
164. > 	X509 *x,*xtmp,*chain_ss=NULL;
165.   	int bad_chain = 0;
166.   	X509_VERIFY_PARAM *param = ctx->param;

crypto/x509/x509_vfy.c:165:2: 
163.   	{
164.   	X509 *x,*xtmp,*chain_ss=NULL;
165. > 	int bad_chain = 0;
166.   	X509_VERIFY_PARAM *param = ctx->param;
167.   	int depth,i,ok=0;

crypto/x509/x509_vfy.c:166:2: 
164.   	X509 *x,*xtmp,*chain_ss=NULL;
165.   	int bad_chain = 0;
166. > 	X509_VERIFY_PARAM *param = ctx->param;
167.   	int depth,i,ok=0;
168.   	int num;

crypto/x509/x509_vfy.c:167:2: 
165.   	int bad_chain = 0;
166.   	X509_VERIFY_PARAM *param = ctx->param;
167. > 	int depth,i,ok=0;
168.   	int num;
169.   	int (*cb)(int xok,X509_STORE_CTX *xctx);

crypto/x509/x509_vfy.c:170:2: 
168.   	int num;
169.   	int (*cb)(int xok,X509_STORE_CTX *xctx);
170. > 	STACK_OF(X509) *sktmp=NULL;
171.   	if (ctx->cert == NULL)
172.   		{

crypto/x509/x509_vfy.c:171:6: Taking false branch
169.   	int (*cb)(int xok,X509_STORE_CTX *xctx);
170.   	STACK_OF(X509) *sktmp=NULL;
171.   	if (ctx->cert == NULL)
            ^
172.   		{
173.   		X509err(X509_F_X509_VERIFY_CERT,X509_R_NO_CERT_SET_FOR_US_TO_VERIFY);

crypto/x509/x509_vfy.c:177:2: 
175.   		}
176.   
177. > 	cb=ctx->verify_cb;
178.   
179.   	/* first we make sure the chain we are going to build is

crypto/x509/x509_vfy.c:181:6: Taking false branch
179.   	/* first we make sure the chain we are going to build is
180.   	 * present and that the first entry is in place */
181.   	if (ctx->chain == NULL)
            ^
182.   		{
183.   		if (	((ctx->chain=sk_X509_new_null()) == NULL) ||

crypto/x509/x509_vfy.c:194:6: Taking false branch
192.   
193.   	/* We use a temporary STACK so we can chop and hack at it */
194.   	if (ctx->untrusted != NULL
            ^
195.   	    && (sktmp=sk_X509_dup(ctx->untrusted)) == NULL)
196.   		{

crypto/x509/x509_vfy.c:201:6: Condition is true
199.   		}
200.   
201.   	num=sk_X509_num(ctx->chain);
            ^
202.   	x=sk_X509_value(ctx->chain,num-1);
203.   	depth=param->depth;

crypto/x509/x509_vfy.c:201:2: 
199.   		}
200.   
201. > 	num=sk_X509_num(ctx->chain);
202.   	x=sk_X509_value(ctx->chain,num-1);
203.   	depth=param->depth;

crypto/stack/stack.c:294:1: start of procedure sk_num()
  292.   	}
  293.   
  294. > int sk_num(const _STACK *st)
  295.   {
  296.   	if(st == NULL) return -1;

crypto/stack/stack.c:296:5: Taking false branch
  294.   int sk_num(const _STACK *st)
  295.   {
  296.   	if(st == NULL) return -1;
             ^
  297.   	return st->num;
  298.   }

crypto/stack/stack.c:297:2: 
  295.   {
  296.   	if(st == NULL) return -1;
  297. > 	return st->num;
  298.   }
  299.   

crypto/stack/stack.c:298:1: return from a call to sk_num
  296.   	if(st == NULL) return -1;
  297.   	return st->num;
  298. > }
  299.   
  300.   void *sk_value(const _STACK *st, int i)

crypto/x509/x509_vfy.c:202:4: Condition is true
200.   
201.   	num=sk_X509_num(ctx->chain);
202.   	x=sk_X509_value(ctx->chain,num-1);
          ^
203.   	depth=param->depth;
204.   

crypto/x509/x509_vfy.c:202:2: 
200.   
201.   	num=sk_X509_num(ctx->chain);
202. > 	x=sk_X509_value(ctx->chain,num-1);
203.   	depth=param->depth;
204.   

crypto/stack/stack.c:300:1: start of procedure sk_value()
  298.   }
  299.   
  300. > void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:302:6: Taking false branch
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:302:13: Taking true branch
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:302:39: 
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:304:1: return from a call to sk_value
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  303.   	return st->data[i];
  304. > }
  305.   
  306.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_vfy.c:203:2: 
201.   	num=sk_X509_num(ctx->chain);
202.   	x=sk_X509_value(ctx->chain,num-1);
203. > 	depth=param->depth;
204.   
205.   

crypto/x509/x509_vfy.c:256:3: Loop condition is true. Entering loop body
254.   			}
255.   		break;
256.   		}
         ^
257.   
258.   	/* at this point, chain should contain a list of untrusted

crypto/x509/x509_vfy.c:209:7: Taking false branch
207.   		{
208.   		/* If we have enough, we break */
209.   		if (depth < num) break; /* FIXME: If this happens, we should take
             ^
210.   		                         * note of it and, if appropriate, use the
211.   		                         * X509_V_ERR_CERT_CHAIN_TOO_LONG error

crypto/x509/x509_vfy.c:216:7: 
214.   
215.   		/* If we are self signed, we break */
216. > 		if (cert_self_signed(x))
217.   			break;
218.   		/* If asked see if we can find issuer in trusted store first */

crypto/x509/x509_vfy.c:153:1: start of procedure cert_self_signed()
  151.   #endif
  152.   /* Return 1 is a certificate is self signed */
  153. > static int cert_self_signed(X509 *x)
  154.   	{
  155.   	X509_check_purpose(x, -1, 0);

crypto/x509/x509_vfy.c:155:2: Skipping X509_check_purpose(): empty list of specs
  153.   static int cert_self_signed(X509 *x)
  154.   	{
  155.   	X509_check_purpose(x, -1, 0);
          ^
  156.   	if (x->ex_flags & EXFLAG_SS)
  157.   		return 1;

crypto/x509/x509_vfy.c:156:6: 
  154.   	{
  155.   	X509_check_purpose(x, -1, 0);
  156. > 	if (x->ex_flags & EXFLAG_SS)
  157.   		return 1;
  158.   	else
