crypto/pkcs7/pk7_doit.c:900: error: NULL_DEREFERENCE
  pointer `*sk` last assigned on line 897 could be null and is dereferenced by call to `sk_X509_ATTRIBUTE_push()` at line 900, column 3.
Showing all 17 steps of the trace


crypto/pkcs7/pk7_doit.c:890:1: start of procedure add_attribute()
888.   	}
889.   
890. > static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype,
891.   			 void *value)
892.   	{

crypto/pkcs7/pk7_doit.c:893:2: 
891.   			 void *value)
892.   	{
893. > 	X509_ATTRIBUTE *attr=NULL;
894.   
895.   	if (*sk == NULL)

crypto/pkcs7/pk7_doit.c:895:6: Taking true branch
893.   	X509_ATTRIBUTE *attr=NULL;
894.   
895.   	if (*sk == NULL)
            ^
896.   		{
897.   		*sk = sk_X509_ATTRIBUTE_new(NULL);

crypto/pkcs7/pk7_doit.c:897:3: 
895.   	if (*sk == NULL)
896.   		{
897. > 		*sk = sk_X509_ATTRIBUTE_new(NULL);
898.   new_attrib:
899.   		attr=X509_ATTRIBUTE_create(nid,atrtype,value);

crypto/x509/x509_vfy.c:638:1: start of procedure sk_X509_ATTRIBUTE_new()
  636.   IMPLEMENT_STACK_OF(X509_NAME)
  637.   
  638. > IMPLEMENT_STACK_OF(X509_ATTRIBUTE)
  639.   IMPLEMENT_ASN1_SET_OF(X509_ATTRIBUTE)

crypto/stack/stack.c:112:1: start of procedure sk_new()
    110.   	}
    111.   
    112. > STACK *sk_new(int (*c)())
    113.   	{
    114.   	STACK *ret;

crypto/stack/stack.c:117:6: Taking true branch
    115.   	int i;
    116.   
    117.   	if ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL)
                ^
    118.   		goto err0;
    119.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)

crypto/stack/stack.c:130:1: 
    128.   err1:
    129.   	Free((char *)ret);
    130. > err0:
    131.   	return(NULL);
    132.   	}

crypto/stack/stack.c:131:2: 
    129.   	Free((char *)ret);
    130.   err0:
    131. > 	return(NULL);
    132.   	}
    133.   

crypto/stack/stack.c:132:2: return from a call to sk_new
    130.   err0:
    131.   	return(NULL);
    132.   	}
            ^
    133.   
    134.   int sk_insert(STACK *st, char *data, int loc)

crypto/x509/x509_vfy.c:638:1: return from a call to sk_X509_ATTRIBUTE_new
  636.   IMPLEMENT_STACK_OF(X509_NAME)
  637.   
  638. > IMPLEMENT_STACK_OF(X509_ATTRIBUTE)
  639.   IMPLEMENT_ASN1_SET_OF(X509_ATTRIBUTE)

crypto/pkcs7/pk7_doit.c:898:1: 
896.   		{
897.   		*sk = sk_X509_ATTRIBUTE_new(NULL);
898. > new_attrib:
899.   		attr=X509_ATTRIBUTE_create(nid,atrtype,value);
900.   		sk_X509_ATTRIBUTE_push(*sk,attr);

crypto/pkcs7/pk7_doit.c:899:3: Skipping X509_ATTRIBUTE_create(): empty list of specs
897.   		*sk = sk_X509_ATTRIBUTE_new(NULL);
898.   new_attrib:
899.   		attr=X509_ATTRIBUTE_create(nid,atrtype,value);
         ^
900.   		sk_X509_ATTRIBUTE_push(*sk,attr);
901.   		}

crypto/pkcs7/pk7_doit.c:900:3: 
898.   new_attrib:
899.   		attr=X509_ATTRIBUTE_create(nid,atrtype,value);
900. > 		sk_X509_ATTRIBUTE_push(*sk,attr);
901.   		}
902.   	else

crypto/x509/x509_vfy.c:638:1: start of procedure sk_X509_ATTRIBUTE_push()
  636.   IMPLEMENT_STACK_OF(X509_NAME)
  637.   
  638. > IMPLEMENT_STACK_OF(X509_ATTRIBUTE)
  639.   IMPLEMENT_ASN1_SET_OF(X509_ATTRIBUTE)

crypto/stack/stack.c:233:1: start of procedure sk_push()
    231.   	}
    232.   
    233. > int sk_push(STACK *st, char *data)
    234.   	{
    235.   	return(sk_insert(st,data,st->num));

crypto/stack/stack.c:235:2: Skipping sk_insert(): empty list of specs
    233.   int sk_push(STACK *st, char *data)
    234.   	{
    235.   	return(sk_insert(st,data,st->num));
            ^
    236.   	}
    237.   

static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype,
			 void *value)
	{
	X509_ATTRIBUTE *attr=NULL;
	if (*sk == NULL)
		{
		*sk = sk_X509_ATTRIBUTE_new(NULL);
new_attrib:
		attr=X509_ATTRIBUTE_create(nid,atrtype,value);
		sk_X509_ATTRIBUTE_push(*sk,attr);
		}
	else
		{
		int i;
		for (i=0; i<sk_X509_ATTRIBUTE_num(*sk); i++)
			{
			attr=sk_X509_ATTRIBUTE_value(*sk,i);
			if (OBJ_obj2nid(attr->object) == nid)
				{
				X509_ATTRIBUTE_free(attr);
				attr=X509_ATTRIBUTE_create(nid,atrtype,value);
				sk_X509_ATTRIBUTE_set(*sk,i,attr);
				goto end;
				}
			}
		goto new_attrib;
		}
end:
	return(1);
	}
['static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype,\n\t\t\t void *value)\n\t{\n\tX509_ATTRIBUTE *attr=NULL;\n\tif (*sk == NULL)\n\t\t{\n\t\t*sk = sk_X509_ATTRIBUTE_new(NULL);\nnew_attrib:\n\t\tattr=X509_ATTRIBUTE_create(nid,atrtype,value);\n\t\tsk_X509_ATTRIBUTE_push(*sk,attr);\n\t\t}\n\telse\n\t\t{\n\t\tint i;\n\t\tfor (i=0; i<sk_X509_ATTRIBUTE_num(*sk); i++)\n\t\t\t{\n\t\t\tattr=sk_X509_ATTRIBUTE_value(*sk,i);\n\t\t\tif (OBJ_obj2nid(attr->object) == nid)\n\t\t\t\t{\n\t\t\t\tX509_ATTRIBUTE_free(attr);\n\t\t\t\tattr=X509_ATTRIBUTE_create(nid,atrtype,value);\n\t\t\t\tsk_X509_ATTRIBUTE_set(*sk,i,attr);\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\t}\n\t\tgoto new_attrib;\n\t\t}\nend:\n\treturn(1);\n\t}', 'IMPLEMENT_STACK_OF(X509_ATTRIBUTE)', 'STACK *sk_new(int (*c)())\n\t{\n\tSTACK *ret;\n\tint i;\n\tif ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL)\n\t\tgoto err0;\n\tif ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)\n\t\tgoto err1;\n\tfor (i=0; i<MIN_NODES; i++)\n\t\tret->data[i]=NULL;\n\tret->comp=c;\n\tret->num_alloc=MIN_NODES;\n\tret->num=0;\n\tret->sorted=0;\n\treturn(ret);\nerr1:\n\tFree((char *)ret);\nerr0:\n\treturn(NULL);\n\t}', 'int sk_push(STACK *st, char *data)\n\t{\n\treturn(sk_insert(st,data,st->num));\n\t}']