crypto/asn1/x_name.c:237: error: NULL_DEREFERENCE
  pointer `entries` last assigned on line 224 could be null and is dereferenced by call to `sk_push()` at line 237, column 7.
Showing all 25 steps of the trace


crypto/asn1/x_name.c:219:1: start of procedure x509_name_encode()
217.   }
218.   
219. > static int x509_name_encode(X509_NAME *a)
220.   {
221.   	STACK *intname = NULL;

crypto/asn1/x_name.c:221:2: 
219.   static int x509_name_encode(X509_NAME *a)
220.   {
221. > 	STACK *intname = NULL;
222.   	int len;
223.   	unsigned char *p;

crypto/asn1/x_name.c:224:2: 
222.   	int len;
223.   	unsigned char *p;
224. > 	STACK_OF(X509_NAME_ENTRY) *entries = NULL;
225.   	X509_NAME_ENTRY *entry;
226.   	int i, set = -1;

crypto/asn1/x_name.c:226:2: 
224.   	STACK_OF(X509_NAME_ENTRY) *entries = NULL;
225.   	X509_NAME_ENTRY *entry;
226. > 	int i, set = -1;
227.   	intname = sk_new_null();
228.   	if(!intname) goto memerr;

crypto/asn1/x_name.c:227:2: 
225.   	X509_NAME_ENTRY *entry;
226.   	int i, set = -1;
227. > 	intname = sk_new_null();
228.   	if(!intname) goto memerr;
229.   	for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {

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

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

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

crypto/asn1/x_name.c:228:6: Taking false branch
226.   	int i, set = -1;
227.   	intname = sk_new_null();
228.   	if(!intname) goto memerr;
            ^
229.   	for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
230.   		entry = sk_X509_NAME_ENTRY_value(a->entries, i);

crypto/asn1/x_name.c:229:6: 
227.   	intname = sk_new_null();
228.   	if(!intname) goto memerr;
229. > 	for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
230.   		entry = sk_X509_NAME_ENTRY_value(a->entries, i);
231.   		if(entry->set != set) {

crypto/asn1/x_name.c:229:13: 
227.   	intname = sk_new_null();
228.   	if(!intname) goto memerr;
229. > 	for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
230.   		entry = sk_X509_NAME_ENTRY_value(a->entries, i);
231.   		if(entry->set != set) {

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

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

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

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

crypto/asn1/x_name.c:229:13: Loop condition is true. Entering loop body
227.   	intname = sk_new_null();
228.   	if(!intname) goto memerr;
229.   	for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
                   ^
230.   		entry = sk_X509_NAME_ENTRY_value(a->entries, i);
231.   		if(entry->set != set) {

crypto/asn1/x_name.c:230:3: 
228.   	if(!intname) goto memerr;
229.   	for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
230. > 		entry = sk_X509_NAME_ENTRY_value(a->entries, i);
231.   		if(entry->set != set) {
232.   			entries = sk_X509_NAME_ENTRY_new_null();

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 false 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:310:2: 
  308.   {
  309.   	if(st == NULL) return NULL;
  310. > 	return st->data[i];
  311.   }
  312.   

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/asn1/x_name.c:231:6: Taking false branch
229.   	for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
230.   		entry = sk_X509_NAME_ENTRY_value(a->entries, i);
231.   		if(entry->set != set) {
            ^
232.   			entries = sk_X509_NAME_ENTRY_new_null();
233.   			if(!entries) goto memerr;

crypto/asn1/x_name.c:237:7: 
235.   			set = entry->set;
236.   		}
237. > 		if(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr;
238.   	}
239.   	len = ASN1_item_ex_i2d((ASN1_VALUE **)&intname, NULL, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);

crypto/stack/stack.c:251:1: start of procedure sk_push()
  249.   	}
  250.   
  251. > int sk_push(STACK *st, char *data)
  252.   	{
  253.   	return(sk_insert(st,data,st->num));

crypto/stack/stack.c:253:2: Skipping sk_insert(): empty list of specs
  251.   int sk_push(STACK *st, char *data)
  252.   	{
  253.   	return(sk_insert(st,data,st->num));
          ^
  254.   	}
  255.   

static int x509_name_encode(X509_NAME *a)
{
	STACK *intname = NULL;
	int len;
	unsigned char *p;
	STACK_OF(X509_NAME_ENTRY) *entries = NULL;
	X509_NAME_ENTRY *entry;
	int i, set = -1;
	intname = sk_new_null();
	if(!intname) goto memerr;
	for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
		entry = sk_X509_NAME_ENTRY_value(a->entries, i);
		if(entry->set != set) {
			entries = sk_X509_NAME_ENTRY_new_null();
			if(!entries) goto memerr;
			if(!sk_push(intname, (char *)entries)) goto memerr;
			set = entry->set;
		}
		if(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr;
	}
	len = ASN1_item_ex_i2d((ASN1_VALUE **)&intname, NULL, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);
	if (!BUF_MEM_grow(a->bytes,len)) goto memerr;
	p=(unsigned char *)a->bytes->data;
	ASN1_item_ex_i2d((ASN1_VALUE **)&intname, &p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);
	sk_pop_free(intname, sk_internal_free);
	a->modified = 0;
	return len;
	memerr:
	sk_pop_free(intname, sk_internal_free);
	ASN1err(ASN1_F_D2I_X509_NAME, ERR_R_MALLOC_FAILURE);
	return -1;
}
['static int x509_name_encode(X509_NAME *a)\n{\n\tSTACK *intname = NULL;\n\tint len;\n\tunsigned char *p;\n\tSTACK_OF(X509_NAME_ENTRY) *entries = NULL;\n\tX509_NAME_ENTRY *entry;\n\tint i, set = -1;\n\tintname = sk_new_null();\n\tif(!intname) goto memerr;\n\tfor(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {\n\t\tentry = sk_X509_NAME_ENTRY_value(a->entries, i);\n\t\tif(entry->set != set) {\n\t\t\tentries = sk_X509_NAME_ENTRY_new_null();\n\t\t\tif(!entries) goto memerr;\n\t\t\tif(!sk_push(intname, (char *)entries)) goto memerr;\n\t\t\tset = entry->set;\n\t\t}\n\t\tif(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr;\n\t}\n\tlen = ASN1_item_ex_i2d((ASN1_VALUE **)&intname, NULL, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);\n\tif (!BUF_MEM_grow(a->bytes,len)) goto memerr;\n\tp=(unsigned char *)a->bytes->data;\n\tASN1_item_ex_i2d((ASN1_VALUE **)&intname, &p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);\n\tsk_pop_free(intname, sk_internal_free);\n\ta->modified = 0;\n\treturn len;\n\tmemerr:\n\tsk_pop_free(intname, sk_internal_free);\n\tASN1err(ASN1_F_D2I_X509_NAME, ERR_R_MALLOC_FAILURE);\n\treturn -1;\n}', '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_value(const STACK *st, int i)\n{\n\tif(st == NULL) return NULL;\n\treturn st->data[i];\n}', 'int sk_push(STACK *st, char *data)\n\t{\n\treturn(sk_insert(st,data,st->num));\n\t}']