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


crypto/x509v3/v3_utl.c:491:1: start of procedure get_email()
489.   
490.   
491. > static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens)
492.   {
493.   	STACK *ret = NULL;

crypto/x509v3/v3_utl.c:493:2: 
491.   static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens)
492.   {
493. > 	STACK *ret = NULL;
494.   	X509_NAME_ENTRY *ne;
495.   	ASN1_IA5STRING *email;

crypto/x509v3/v3_utl.c:499:2: 
497.   	int i;
498.   	/* Now add any email address(es) to STACK */
499. > 	i = -1;
500.   	/* First supplied X509_NAME */
501.   	while((i = X509_NAME_get_index_by_NID(name,

crypto/x509v3/v3_utl.c:501:8: 
499.   	i = -1;
500.   	/* First supplied X509_NAME */
501. > 	while((i = X509_NAME_get_index_by_NID(name,
502.   					 NID_pkcs9_emailAddress, i)) >= 0) {
503.   		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:270:1: start of procedure OBJ_nid2obj()
    268.   	}
    269.   
    270. > ASN1_OBJECT *OBJ_nid2obj(int n)
    271.   	{
    272.   	ADDED_OBJ ad,*adp;

crypto/objects/obj_dat.c:275:7: Taking true branch
    273.   	ASN1_OBJECT ob;
    274.   
    275.   	if ((n >= 0) && (n < NUM_NID))
                 ^
    276.   		{
    277.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:275:19: Taking true branch
    273.   	ASN1_OBJECT ob;
    274.   
    275.   	if ((n >= 0) && (n < NUM_NID))
                             ^
    276.   		{
    277.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:277:8: Taking true branch
    275.   	if ((n >= 0) && (n < NUM_NID))
    276.   		{
    277.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
                  ^
    278.   			{
    279.   			OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:277:28: Taking false branch
    275.   	if ((n >= 0) && (n < NUM_NID))
    276.   		{
    277.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
                                      ^
    278.   			{
    279.   			OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:282:3: 
    280.   			return(NULL);
    281.   			}
    282. > 		return((ASN1_OBJECT *)&(nid_objs[n]));
    283.   		}
    284.   	else if (added == NULL)

crypto/objects/obj_dat.c:300:2: return from a call to OBJ_nid2obj
    298.   			}
    299.   		}
    300.   	}
            ^
    301.   
    302.   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:501:8: Loop condition is true. Entering loop body
499.   	i = -1;
500.   	/* First supplied X509_NAME */
501.   	while((i = X509_NAME_get_index_by_NID(name,
              ^
502.   					 NID_pkcs9_emailAddress, i)) >= 0) {
503.   		ne = X509_NAME_get_entry(name, i);

crypto/x509v3/v3_utl.c:503:3: 
501.   	while((i = X509_NAME_get_index_by_NID(name,
502.   					 NID_pkcs9_emailAddress, i)) >= 0) {
503. > 		ne = X509_NAME_get_entry(name, i);
504.   		email = X509_NAME_ENTRY_get_data(ne);
505.   		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: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/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:307:1: start of procedure sk_value()
    305.   }
    306.   
    307. > char *sk_value(const STACK *st, int i)
    308.   {
    309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:309:6: Taking false branch
    307.   char *sk_value(const STACK *st, int i)
    308.   {
    309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                ^
    310.   	return st->data[i];
    311.   }

crypto/stack/stack.c:309:13: Taking false branch
    307.   char *sk_value(const STACK *st, int i)
    308.   {
    309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                       ^
    310.   	return st->data[i];
    311.   }

crypto/stack/stack.c:309:24: Taking false branch
    307.   char *sk_value(const STACK *st, int i)
    308.   {
    309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                  ^
    310.   	return st->data[i];
    311.   }

crypto/stack/stack.c:310:2: 
    308.   {
    309.   	if(!st || (i < 0) || (i >= st->num)) 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 || (i < 0) || (i >= st->num)) return NULL;
    310.   	return st->data[i];
    311. > }
    312.   
    313.   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:504:3: 
502.   					 NID_pkcs9_emailAddress, i)) >= 0) {
503.   		ne = X509_NAME_get_entry(name, i);
504. > 		email = X509_NAME_ENTRY_get_data(ne);
505.   		if(!append_ia5(&ret, email)) return NULL;
506.   	}

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:505:7: 
503.   		ne = X509_NAME_get_entry(name, i);
504.   		email = X509_NAME_ENTRY_get_data(ne);
505. > 		if(!append_ia5(&ret, email)) return NULL;
506.   	}
507.   	for(i = 0; i < sk_GENERAL_NAME_num(gens); i++)

crypto/x509v3/v3_utl.c:521:1: start of procedure append_ia5()
  519.   }
  520.   
  521. > static int append_ia5(STACK **sk, ASN1_IA5STRING *email)
  522.   {
  523.   	char *emtmp;

crypto/x509v3/v3_utl.c:525:5: 
  523.   	char *emtmp;
  524.   	/* First some sanity checks */
  525. > 	if(email->type != V_ASN1_IA5STRING) return 1;
  526.   	if(!email->data || !email->length) return 1;
  527.   	if(!*sk) *sk = sk_new(sk_strcmp);
