crypto/pkcs7/example.c:23: error: NULL_DEREFERENCE
  pointer `so` last assigned on line 22 could be null and is dereferenced at line 23, column 6.
Showing all 19 steps of the trace


crypto/pkcs7/example.c:18:1: start of procedure get_signed_time()
16.   	}
17.   
18. > ASN1_UTCTIME *get_signed_time(PKCS7_SIGNER_INFO *si)
19.   	{
20.   	ASN1_TYPE *so;

crypto/pkcs7/example.c:22:2: 
20.   	ASN1_TYPE *so;
21.   
22. > 	so=PKCS7_get_signed_attribute(si,NID_pkcs9_signingTime);
23.   	if (so->type == V_ASN1_UTCTIME)
24.   	    return so->value.utctime;

crypto/pkcs7/pk7_doit.c:813:1: start of procedure PKCS7_get_signed_attribute()
  811.   	}
  812.   
  813. > ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid)
  814.   	{
  815.   	return(get_attribute(si->auth_attr,nid));

crypto/pkcs7/pk7_doit.c:815:2: 
  813.   ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid)
  814.   	{
  815. > 	return(get_attribute(si->auth_attr,nid));
  816.   	}
  817.   

crypto/pkcs7/pk7_doit.c:823:1: start of procedure get_attribute()
    821.   	}
    822.   
    823. > static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid)
    824.   	{
    825.   	int i;

crypto/pkcs7/pk7_doit.c:829:2: 
    827.   	ASN1_OBJECT *o;
    828.   
    829. > 	o=OBJ_nid2obj(nid);
    830.   	if (!o || !sk) return(NULL);
    831.   	for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)

crypto/objects/obj_dat.c:258:1: start of procedure OBJ_nid2obj()
      256.   	}
      257.   
      258. > ASN1_OBJECT *OBJ_nid2obj(int n)
      259.   	{
      260.   	ADDED_OBJ ad,*adp;

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

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

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

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

crypto/objects/obj_dat.c:270:3: 
      268.   			return(NULL);
      269.   			}
      270. > 		return((ASN1_OBJECT *)&(nid_objs[n]));
      271.   		}
      272.   	else if (added == NULL)

crypto/objects/obj_dat.c:288:2: return from a call to OBJ_nid2obj
      286.   			}
      287.   		}
      288.   	}
              ^
      289.   
      290.   const char *OBJ_nid2sn(int n)

crypto/pkcs7/pk7_doit.c:830:7: Taking false branch
    828.   
    829.   	o=OBJ_nid2obj(nid);
    830.   	if (!o || !sk) return(NULL);
                 ^
    831.   	for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
    832.   		{

crypto/pkcs7/pk7_doit.c:830:13: Taking true branch
    828.   
    829.   	o=OBJ_nid2obj(nid);
    830.   	if (!o || !sk) return(NULL);
                       ^
    831.   	for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
    832.   		{

crypto/pkcs7/pk7_doit.c:830:17: 
    828.   
    829.   	o=OBJ_nid2obj(nid);
    830. > 	if (!o || !sk) return(NULL);
    831.   	for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
    832.   		{

crypto/pkcs7/pk7_doit.c:843:2: return from a call to get_attribute
    841.   		}
    842.   	return(NULL);
    843.   	}
            ^
    844.   
    845.   ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk)

crypto/pkcs7/pk7_doit.c:816:2: return from a call to PKCS7_get_signed_attribute
  814.   	{
  815.   	return(get_attribute(si->auth_attr,nid));
  816.   	}
          ^
  817.   
  818.   ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid)

crypto/pkcs7/example.c:23:6: 
21.   
22.   	so=PKCS7_get_signed_attribute(si,NID_pkcs9_signingTime);
23. > 	if (so->type == V_ASN1_UTCTIME)
24.   	    return so->value.utctime;
25.   	return NULL;

ASN1_UTCTIME *get_signed_time(PKCS7_SIGNER_INFO *si)
	{
	ASN1_TYPE *so;
	so=PKCS7_get_signed_attribute(si,NID_pkcs9_signingTime);
	if (so->type == V_ASN1_UTCTIME)
	    return so->value.utctime;
	return NULL;
	}
['ASN1_UTCTIME *get_signed_time(PKCS7_SIGNER_INFO *si)\n\t{\n\tASN1_TYPE *so;\n\tso=PKCS7_get_signed_attribute(si,NID_pkcs9_signingTime);\n\tif (so->type == V_ASN1_UTCTIME)\n\t    return so->value.utctime;\n\treturn NULL;\n\t}', 'ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid)\n\t{\n\treturn(get_attribute(si->auth_attr,nid));\n\t}', 'static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid)\n\t{\n\tint i;\n\tX509_ATTRIBUTE *xa;\n\tASN1_OBJECT *o;\n\to=OBJ_nid2obj(nid);\n\tif (!o || !sk) return(NULL);\n\tfor (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)\n\t\t{\n\t\txa=sk_X509_ATTRIBUTE_value(sk,i);\n\t\tif (OBJ_cmp(xa->object,o) == 0)\n\t\t\t{\n\t\t\tif (xa->set && sk_ASN1_TYPE_num(xa->value.set))\n\t\t\t\treturn(sk_ASN1_TYPE_value(xa->value.set,0));\n\t\t\telse\n\t\t\t\treturn(NULL);\n\t\t\t}\n\t\t}\n\treturn(NULL);\n\t}', 'ASN1_OBJECT *OBJ_nid2obj(int n)\n\t{\n\tADDED_OBJ ad,*adp;\n\tASN1_OBJECT ob;\n\tif ((n >= 0) && (n < NUM_NID))\n\t\t{\n\t\tif ((n != NID_undef) && (nid_objs[n].nid == NID_undef))\n\t\t\t{\n\t\t\tOBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\treturn((ASN1_OBJECT *)&(nid_objs[n]));\n\t\t}\n\telse if (added == NULL)\n\t\treturn(NULL);\n\telse\n\t\t{\n\t\tad.type=ADDED_NID;\n\t\tad.obj= &ob;\n\t\tob.nid=n;\n\t\tadp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad);\n\t\tif (adp != NULL)\n\t\t\treturn(adp->obj);\n\t\telse\n\t\t\t{\n\t\t\tOBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\t}\n\t}']