crypto/x509v3/v3_utl.c:478: error: NULL_DEREFERENCE
  pointer `email` last assigned on line 477 could be null and is dereferenced by call to `append_ia5()` at line 478, column 7.
Showing all 41 steps of the trace


crypto/x509v3/v3_utl.c:464:1: start of procedure get_email()
462.   
463.   
464. > static STACK *get_email(X509_NAME *name, STACK_OF(GENERAL_NAME) *gens)
465.   {
466.   	STACK *ret = NULL;

crypto/x509v3/v3_utl.c:466:2: 
464.   static STACK *get_email(X509_NAME *name, STACK_OF(GENERAL_NAME) *gens)
465.   {
466. > 	STACK *ret = NULL;
467.   	X509_NAME_ENTRY *ne;
468.   	ASN1_IA5STRING *email;

crypto/x509v3/v3_utl.c:472:2: 
470.   	int i;
471.   	/* Now add any email address(es) to STACK */
472. > 	i = -1;
473.   	/* First supplied X509_NAME */
474.   	while((i = X509_NAME_get_index_by_NID(name,

crypto/x509v3/v3_utl.c:474:8: 
472.   	i = -1;
473.   	/* First supplied X509_NAME */
474. > 	while((i = X509_NAME_get_index_by_NID(name,
475.   					 NID_pkcs9_emailAddress, i)) > 0) {
476.   		ne = X509_NAME_get_entry(name, i);

crypto/x509/x509name.c:98:1: start of procedure X509_NAME_get_index_by_NID()
  96.   	}
  97.   
  98. > int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos)
  99.   	{
  100.   	ASN1_OBJECT *obj;

crypto/x509/x509name.c:102:2: 
  100.   	ASN1_OBJECT *obj;
  101.   
  102. > 	obj=OBJ_nid2obj(nid);
  103.   	if (obj == NULL) return(-2);
  104.   	return(X509_NAME_get_index_by_OBJ(name,obj,lastpos));

crypto/objects/obj_dat.c:262:1: start of procedure OBJ_nid2obj()
    260.   	}
    261.   
    262. > ASN1_OBJECT *OBJ_nid2obj(int n)
    263.   	{
    264.   	ADDED_OBJ ad,*adp;

crypto/objects/obj_dat.c:267:7: Taking true branch
    265.   	ASN1_OBJECT ob;
    266.   
    267.   	if ((n >= 0) && (n < NUM_NID))
                 ^
    268.   		{
    269.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:267:19: Taking true branch
    265.   	ASN1_OBJECT ob;
    266.   
    267.   	if ((n >= 0) && (n < NUM_NID))
                             ^
    268.   		{
    269.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:269:8: Taking true branch
    267.   	if ((n >= 0) && (n < NUM_NID))
    268.   		{
    269.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
                  ^
    270.   			{
    271.   			OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:269:28: Taking false branch
    267.   	if ((n >= 0) && (n < NUM_NID))
    268.   		{
    269.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
                                      ^
    270.   			{
    271.   			OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:274:3: 
    272.   			return(NULL);
    273.   			}
    274. > 		return((ASN1_OBJECT *)&(nid_objs[n]));
    275.   		}
    276.   	else if (added == NULL)

crypto/objects/obj_dat.c:292:2: return from a call to OBJ_nid2obj
    290.   			}
    291.   		}
    292.   	}
            ^
    293.   
    294.   const char *OBJ_nid2sn(int n)

crypto/x509/x509name.c:103:6: Taking false branch
  101.   
  102.   	obj=OBJ_nid2obj(nid);
  103.   	if (obj == NULL) return(-2);
              ^
  104.   	return(X509_NAME_get_index_by_OBJ(name,obj,lastpos));
  105.   	}

crypto/x509/x509name.c:104:2: Skipping X509_NAME_get_index_by_OBJ(): empty list of specs
  102.   	obj=OBJ_nid2obj(nid);
  103.   	if (obj == NULL) return(-2);
  104.   	return(X509_NAME_get_index_by_OBJ(name,obj,lastpos));
          ^
  105.   	}
  106.   

crypto/x509/x509name.c:105:2: return from a call to X509_NAME_get_index_by_NID
  103.   	if (obj == NULL) return(-2);
  104.   	return(X509_NAME_get_index_by_OBJ(name,obj,lastpos));
  105.   	}
          ^
  106.   
  107.   /* NOTE: you should be passsing -1, not 0 as lastpos */

crypto/x509v3/v3_utl.c:474:8: Loop condition is true. Entering loop body
472.   	i = -1;
473.   	/* First supplied X509_NAME */
474.   	while((i = X509_NAME_get_index_by_NID(name,
              ^
475.   					 NID_pkcs9_emailAddress, i)) > 0) {
476.   		ne = X509_NAME_get_entry(name, i);

crypto/x509v3/v3_utl.c:476:3: 
474.   	while((i = X509_NAME_get_index_by_NID(name,
475.   					 NID_pkcs9_emailAddress, i)) > 0) {
476. > 		ne = X509_NAME_get_entry(name, i);
477.   		email = X509_NAME_ENTRY_get_data(ne);
478.   		if(!append_ia5(&ret, email)) return NULL;

crypto/x509/x509name.c:129:1: start of procedure X509_NAME_get_entry()
  127.   	}
  128.   
  129. > X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc)
  130.   	{
  131.   	if(name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc

crypto/x509/x509name.c:131:5: Taking false branch
  129.   X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc)
  130.   	{
  131.   	if(name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
             ^
  132.   	   || loc < 0)
  133.   		return(NULL);

crypto/x509/x509name.c:131:21: 
  129.   X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc)
  130.   	{
  131. > 	if(name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
  132.   	   || loc < 0)
  133.   		return(NULL);

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)

crypto/x509/x509name.c:131:21: Taking false branch
  129.   X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc)
  130.   	{
  131.   	if(name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
                             ^
  132.   	   || loc < 0)
  133.   		return(NULL);

crypto/x509/x509name.c:132:8: Taking false branch
  130.   	{
  131.   	if(name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
  132.   	   || loc < 0)
                ^
  133.   		return(NULL);
  134.   	else

crypto/x509/x509name.c:135:3: 
  133.   		return(NULL);
  134.   	else
  135. > 		return(sk_X509_NAME_ENTRY_value(name->entries,loc));
  136.   	}
  137.   

crypto/stack/stack.c:305:1: start of procedure sk_value()
    303.   }
    304.   
    305. > char *sk_value(const STACK *st, int i)
    306.   {
    307.   	if(st == NULL) return NULL;

crypto/stack/stack.c:307:5: Taking false branch
    305.   char *sk_value(const STACK *st, int i)
    306.   {
    307.   	if(st == NULL) return NULL;
               ^
    308.   	return st->data[i];
    309.   }

crypto/stack/stack.c:308:2: 
    306.   {
    307.   	if(st == NULL) return NULL;
    308. > 	return st->data[i];
    309.   }
    310.   

crypto/stack/stack.c:309:1: return from a call to sk_value
    307.   	if(st == NULL) return NULL;
    308.   	return st->data[i];
    309. > }
    310.   
    311.   char *sk_set(STACK *st, int i, char *value)

crypto/x509/x509name.c:136:2: return from a call to X509_NAME_get_entry
  134.   	else
  135.   		return(sk_X509_NAME_ENTRY_value(name->entries,loc));
  136.   	}
          ^
  137.   
  138.   X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc)

crypto/x509v3/v3_utl.c:477:3: 
475.   					 NID_pkcs9_emailAddress, i)) > 0) {
476.   		ne = X509_NAME_get_entry(name, i);
477. > 		email = X509_NAME_ENTRY_get_data(ne);
478.   		if(!append_ia5(&ret, email)) return NULL;
479.   	}

crypto/x509/x509name.c:378:1: start of procedure X509_NAME_ENTRY_get_data()
  376.   	}
  377.   
  378. > ASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne)
  379.   	{
  380.   	if (ne == NULL) return(NULL);

crypto/x509/x509name.c:380:6: Taking true branch
  378.   ASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne)
  379.   	{
  380.   	if (ne == NULL) return(NULL);
              ^
  381.   	return(ne->value);
  382.   	}

crypto/x509/x509name.c:380:18: 
  378.   ASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne)
  379.   	{
  380. > 	if (ne == NULL) return(NULL);
  381.   	return(ne->value);
  382.   	}

crypto/x509/x509name.c:382:2: return from a call to X509_NAME_ENTRY_get_data
  380.   	if (ne == NULL) return(NULL);
  381.   	return(ne->value);
  382.   	}
          ^
  383.   

crypto/x509v3/v3_utl.c:478:7: 
476.   		ne = X509_NAME_get_entry(name, i);
477.   		email = X509_NAME_ENTRY_get_data(ne);
478. > 		if(!append_ia5(&ret, email)) return NULL;
479.   	}
480.   	for(i = 0; i < sk_GENERAL_NAME_num(gens); i++)

crypto/x509v3/v3_utl.c:494:1: start of procedure append_ia5()
  492.   }
  493.   
  494. > static int append_ia5(STACK **sk, ASN1_IA5STRING *email)
  495.   {
  496.   	char *emtmp;

crypto/x509v3/v3_utl.c:498:5: 
  496.   	char *emtmp;
  497.   	/* First some sanity checks */
  498. > 	if(email->type != V_ASN1_IA5STRING) return 1;
  499.   	if(!email->data || !email->length) return 1;
  500.   	if(!*sk) *sk = sk_new(sk_strcmp);
