apps/verify.c:336: error: NULL_DEREFERENCE
  pointer `xi` last assigned on line 335 could be null and is dereferenced at line 336, column 7.
Showing all 24 steps of the trace


apps/verify.c:309:1: start of procedure load_untrusted()
307.   	}
308.   
309. > static STACK_OF(X509) *load_untrusted(char *certfile)
310.   {
311.   	STACK_OF(X509_INFO) *sk=NULL;

apps/verify.c:311:2: 
309.   static STACK_OF(X509) *load_untrusted(char *certfile)
310.   {
311. > 	STACK_OF(X509_INFO) *sk=NULL;
312.   	STACK_OF(X509) *stack=NULL, *ret=NULL;
313.   	BIO *in=NULL;

apps/verify.c:312:2: 
310.   {
311.   	STACK_OF(X509_INFO) *sk=NULL;
312. > 	STACK_OF(X509) *stack=NULL, *ret=NULL;
313.   	BIO *in=NULL;
314.   	X509_INFO *xi;

apps/verify.c:313:2: 
311.   	STACK_OF(X509_INFO) *sk=NULL;
312.   	STACK_OF(X509) *stack=NULL, *ret=NULL;
313. > 	BIO *in=NULL;
314.   	X509_INFO *xi;
315.   

apps/verify.c:316:7: 
314.   	X509_INFO *xi;
315.   
316. > 	if(!(stack = sk_X509_new_null())) {
317.   		BIO_printf(bio_err,"memory allocation failure\n");
318.   		goto end;

crypto/stack/stack.c:112:1: start of procedure sk_new_null()
  110.   	}
  111.   
  112. > STACK *sk_new_null(void)
  113.   	{
  114.   	return sk_new((int (*)(const char * const *, const char * const *))0);

crypto/stack/stack.c:114:2: Skipping sk_new(): empty list of specs
  112.   STACK *sk_new_null(void)
  113.   	{
  114.   	return sk_new((int (*)(const char * const *, const char * const *))0);
          ^
  115.   	}
  116.   

crypto/stack/stack.c:115:2: return from a call to sk_new_null
  113.   	{
  114.   	return sk_new((int (*)(const char * const *, const char * const *))0);
  115.   	}
          ^
  116.   
  117.   STACK *sk_new(int (*c)(const char * const *, const char * const *))

apps/verify.c:316:7: Taking false branch
314.   	X509_INFO *xi;
315.   
316.   	if(!(stack = sk_X509_new_null())) {
             ^
317.   		BIO_printf(bio_err,"memory allocation failure\n");
318.   		goto end;

apps/verify.c:321:7: Taking false branch
319.   	}
320.   
321.   	if(!(in=BIO_new_file(certfile, "r"))) {
             ^
322.   		BIO_printf(bio_err,"error opening the file, %s\n",certfile);
323.   		goto end;

apps/verify.c:327:7: Taking false branch
325.   
326.   	/* This loads from a file, a stack of x509/crl/pkey sets */
327.   	if(!(sk=PEM_X509_INFO_read_bio(in,NULL,NULL,NULL))) {
             ^
328.   		BIO_printf(bio_err,"error reading the file, %s\n",certfile);
329.   		goto end;

apps/verify.c:333:9: 
331.   
332.   	/* scan over it and pull out the certs */
333. > 	while (sk_X509_INFO_num(sk))
334.   		{
335.   		xi=sk_X509_INFO_shift(sk);

crypto/stack/stack.c:299:1: start of procedure sk_num()
  297.   	}
  298.   
  299. > int sk_num(const STACK *st)
  300.   {
  301.   	if(st == NULL) return -1;

crypto/stack/stack.c:301:5: Taking false branch
  299.   int sk_num(const STACK *st)
  300.   {
  301.   	if(st == NULL) return -1;
             ^
  302.   	return st->num;
  303.   }

crypto/stack/stack.c:302:2: 
  300.   {
  301.   	if(st == NULL) return -1;
  302. > 	return st->num;
  303.   }
  304.   

crypto/stack/stack.c:303:1: return from a call to sk_num
  301.   	if(st == NULL) return -1;
  302.   	return st->num;
  303. > }
  304.   
  305.   char *sk_value(const STACK *st, int i)

apps/verify.c:333:9: Loop condition is true. Entering loop body
331.   
332.   	/* scan over it and pull out the certs */
333.   	while (sk_X509_INFO_num(sk))
               ^
334.   		{
335.   		xi=sk_X509_INFO_shift(sk);

apps/verify.c:335:3: 
333.   	while (sk_X509_INFO_num(sk))
334.   		{
335. > 		xi=sk_X509_INFO_shift(sk);
336.   		if (xi->x509 != NULL)
337.   			{

crypto/stack/stack.c:259:1: start of procedure sk_shift()
  257.   	}
  258.   
  259. > char *sk_shift(STACK *st)
  260.   	{
  261.   	if (st == NULL) return(NULL);

crypto/stack/stack.c:261:6: Taking false branch
  259.   char *sk_shift(STACK *st)
  260.   	{
  261.   	if (st == NULL) return(NULL);
              ^
  262.   	if (st->num <= 0) return(NULL);
  263.   	return(sk_delete(st,0));

crypto/stack/stack.c:262:6: Taking true branch
  260.   	{
  261.   	if (st == NULL) return(NULL);
  262.   	if (st->num <= 0) return(NULL);
              ^
  263.   	return(sk_delete(st,0));
  264.   	}

crypto/stack/stack.c:262:20: 
  260.   	{
  261.   	if (st == NULL) return(NULL);
  262. > 	if (st->num <= 0) return(NULL);
  263.   	return(sk_delete(st,0));
  264.   	}

crypto/stack/stack.c:264:2: return from a call to sk_shift
  262.   	if (st->num <= 0) return(NULL);
  263.   	return(sk_delete(st,0));
  264.   	}
          ^
  265.   
  266.   char *sk_pop(STACK *st)

apps/verify.c:336:7: 
334.   		{
335.   		xi=sk_X509_INFO_shift(sk);
336. > 		if (xi->x509 != NULL)
337.   			{
338.   			sk_X509_push(stack,xi->x509);

static STACK_OF(X509) *load_untrusted(char *certfile)
{
	STACK_OF(X509_INFO) *sk=NULL;
	STACK_OF(X509) *stack=NULL, *ret=NULL;
	BIO *in=NULL;
	X509_INFO *xi;
	if(!(stack = sk_X509_new_null())) {
		BIO_printf(bio_err,"memory allocation failure\n");
		goto end;
	}
	if(!(in=BIO_new_file(certfile, "r"))) {
		BIO_printf(bio_err,"error opening the file, %s\n",certfile);
		goto end;
	}
	if(!(sk=PEM_X509_INFO_read_bio(in,NULL,NULL,NULL))) {
		BIO_printf(bio_err,"error reading the file, %s\n",certfile);
		goto end;
	}
	while (sk_X509_INFO_num(sk))
		{
		xi=sk_X509_INFO_shift(sk);
		if (xi->x509 != NULL)
			{
			sk_X509_push(stack,xi->x509);
			xi->x509=NULL;
			}
		X509_INFO_free(xi);
		}
	if(!sk_X509_num(stack)) {
		BIO_printf(bio_err,"no certificates in file, %s\n",certfile);
		sk_X509_free(stack);
		goto end;
	}
	ret=stack;
end:
	BIO_free(in);
	sk_X509_INFO_free(sk);
	return(ret);
	}
['static STACK_OF(X509) *load_untrusted(char *certfile)\n{\n\tSTACK_OF(X509_INFO) *sk=NULL;\n\tSTACK_OF(X509) *stack=NULL, *ret=NULL;\n\tBIO *in=NULL;\n\tX509_INFO *xi;\n\tif(!(stack = sk_X509_new_null())) {\n\t\tBIO_printf(bio_err,"memory allocation failure\\n");\n\t\tgoto end;\n\t}\n\tif(!(in=BIO_new_file(certfile, "r"))) {\n\t\tBIO_printf(bio_err,"error opening the file, %s\\n",certfile);\n\t\tgoto end;\n\t}\n\tif(!(sk=PEM_X509_INFO_read_bio(in,NULL,NULL,NULL))) {\n\t\tBIO_printf(bio_err,"error reading the file, %s\\n",certfile);\n\t\tgoto end;\n\t}\n\twhile (sk_X509_INFO_num(sk))\n\t\t{\n\t\txi=sk_X509_INFO_shift(sk);\n\t\tif (xi->x509 != NULL)\n\t\t\t{\n\t\t\tsk_X509_push(stack,xi->x509);\n\t\t\txi->x509=NULL;\n\t\t\t}\n\t\tX509_INFO_free(xi);\n\t\t}\n\tif(!sk_X509_num(stack)) {\n\t\tBIO_printf(bio_err,"no certificates in file, %s\\n",certfile);\n\t\tsk_X509_free(stack);\n\t\tgoto end;\n\t}\n\tret=stack;\nend:\n\tBIO_free(in);\n\tsk_X509_INFO_free(sk);\n\treturn(ret);\n\t}', 'STACK *sk_new_null(void)\n\t{\n\treturn sk_new((int (*)(const char * const *, const char * const *))0);\n\t}', 'int sk_num(const STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}', 'char *sk_shift(STACK *st)\n\t{\n\tif (st == NULL) return(NULL);\n\tif (st->num <= 0) return(NULL);\n\treturn(sk_delete(st,0));\n\t}']