crypto/x509/x509_vfy.c:811: error: NULL_DEREFERENCE
  pointer `ptmp` last assigned on line 810 could be null and is dereferenced at line 811, column 7.
Showing all 20 steps of the trace


crypto/x509/x509_vfy.c:793:1: start of procedure X509_STORE_CTX_purpose_inherit()
791.    */
792.   
793. > int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
794.   				int purpose, int trust)
795.   {

crypto/x509/x509_vfy.c:798:7: Taking false branch
796.   	int idx;
797.   	/* If purpose not set use default */
798.   	if (!purpose) purpose = def_purpose;
             ^
799.   	/* If we have a purpose then check it is valid */
800.   	if (purpose)

crypto/x509/x509_vfy.c:800:6: Taking true branch
798.   	if (!purpose) purpose = def_purpose;
799.   	/* If we have a purpose then check it is valid */
800.   	if (purpose)
            ^
801.   		{
802.   		X509_PURPOSE *ptmp;

crypto/x509/x509_vfy.c:803:3: 
801.   		{
802.   		X509_PURPOSE *ptmp;
803. > 		idx = X509_PURPOSE_get_by_id(purpose);
804.   		if (idx == -1)
805.   			{

crypto/x509v3/v3_purp.c:148:1: start of procedure X509_PURPOSE_get_by_id()
  146.   
  147.   
  148. > int X509_PURPOSE_get_by_id(int purpose)
  149.   {
  150.   	X509_PURPOSE tmp;

crypto/x509v3/v3_purp.c:152:6: Taking true branch
  150.   	X509_PURPOSE tmp;
  151.   	int idx;
  152.   	if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
              ^
  153.   		return purpose - X509_PURPOSE_MIN;
  154.   	tmp.purpose = purpose;

crypto/x509v3/v3_purp.c:152:39: Taking false branch
  150.   	X509_PURPOSE tmp;
  151.   	int idx;
  152.   	if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
                                               ^
  153.   		return purpose - X509_PURPOSE_MIN;
  154.   	tmp.purpose = purpose;

crypto/x509v3/v3_purp.c:154:2: 
  152.   	if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
  153.   		return purpose - X509_PURPOSE_MIN;
  154. > 	tmp.purpose = purpose;
  155.   	if(!xptable) return -1;
  156.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);

crypto/x509v3/v3_purp.c:155:6: Taking false branch
  153.   		return purpose - X509_PURPOSE_MIN;
  154.   	tmp.purpose = purpose;
  155.   	if(!xptable) return -1;
              ^
  156.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);
  157.   	if(idx == -1) return -1;

crypto/x509v3/v3_purp.c:156:2: Skipping sk_find(): empty list of specs
  154.   	tmp.purpose = purpose;
  155.   	if(!xptable) return -1;
  156.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);
          ^
  157.   	if(idx == -1) return -1;
  158.   	return idx + X509_PURPOSE_COUNT;

crypto/x509v3/v3_purp.c:157:5: Taking false branch
  155.   	if(!xptable) return -1;
  156.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);
  157.   	if(idx == -1) return -1;
             ^
  158.   	return idx + X509_PURPOSE_COUNT;
  159.   }

crypto/x509v3/v3_purp.c:158:2: 
  156.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);
  157.   	if(idx == -1) return -1;
  158. > 	return idx + X509_PURPOSE_COUNT;
  159.   }
  160.   

crypto/x509v3/v3_purp.c:159:1: return from a call to X509_PURPOSE_get_by_id
  157.   	if(idx == -1) return -1;
  158.   	return idx + X509_PURPOSE_COUNT;
  159. > }
  160.   
  161.   int X509_PURPOSE_add(int id, int trust, int flags,

crypto/x509/x509_vfy.c:804:7: Taking false branch
802.   		X509_PURPOSE *ptmp;
803.   		idx = X509_PURPOSE_get_by_id(purpose);
804.   		if (idx == -1)
             ^
805.   			{
806.   			X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,

crypto/x509/x509_vfy.c:810:3: 
808.   			return 0;
809.   			}
810. > 		ptmp = X509_PURPOSE_get0(idx);
811.   		if (ptmp->trust == X509_TRUST_DEFAULT)
812.   			{

crypto/x509v3/v3_purp.c:129:1: start of procedure X509_PURPOSE_get0()
  127.   }
  128.   
  129. > X509_PURPOSE * X509_PURPOSE_get0(int idx)
  130.   {
  131.   	if(idx < 0) return NULL;

crypto/x509v3/v3_purp.c:131:5: Taking true branch
  129.   X509_PURPOSE * X509_PURPOSE_get0(int idx)
  130.   {
  131.   	if(idx < 0) return NULL;
             ^
  132.   	if(idx < X509_PURPOSE_COUNT) return xstandard + idx;
  133.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);

crypto/x509v3/v3_purp.c:131:14: 
  129.   X509_PURPOSE * X509_PURPOSE_get0(int idx)
  130.   {
  131. > 	if(idx < 0) return NULL;
  132.   	if(idx < X509_PURPOSE_COUNT) return xstandard + idx;
  133.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);

crypto/x509v3/v3_purp.c:134:1: return from a call to X509_PURPOSE_get0
  132.   	if(idx < X509_PURPOSE_COUNT) return xstandard + idx;
  133.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  134. > }
  135.   
  136.   int X509_PURPOSE_get_by_sname(char *sname)

crypto/x509/x509_vfy.c:811:7: 
809.   			}
810.   		ptmp = X509_PURPOSE_get0(idx);
811. > 		if (ptmp->trust == X509_TRUST_DEFAULT)
812.   			{
813.   			idx = X509_PURPOSE_get_by_id(def_purpose);

int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
				int purpose, int trust)
{
	int idx;
	if (!purpose) purpose = def_purpose;
	if (purpose)
		{
		X509_PURPOSE *ptmp;
		idx = X509_PURPOSE_get_by_id(purpose);
		if (idx == -1)
			{
			X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
						X509_R_UNKNOWN_PURPOSE_ID);
			return 0;
			}
		ptmp = X509_PURPOSE_get0(idx);
		if (ptmp->trust == X509_TRUST_DEFAULT)
			{
			idx = X509_PURPOSE_get_by_id(def_purpose);
			if (idx == -1)
				{
				X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
						X509_R_UNKNOWN_PURPOSE_ID);
				return 0;
				}
			ptmp = X509_PURPOSE_get0(idx);
			}
		if (!trust) trust = ptmp->trust;
		}
	if (trust)
		{
		idx = X509_TRUST_get_by_id(trust);
		if (idx == -1)
			{
			X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
						X509_R_UNKNOWN_TRUST_ID);
			return 0;
			}
		}
	if (purpose) ctx->purpose = purpose;
	if (trust) ctx->trust = trust;
	return 1;
}
['int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,\n\t\t\t\tint purpose, int trust)\n{\n\tint idx;\n\tif (!purpose) purpose = def_purpose;\n\tif (purpose)\n\t\t{\n\t\tX509_PURPOSE *ptmp;\n\t\tidx = X509_PURPOSE_get_by_id(purpose);\n\t\tif (idx == -1)\n\t\t\t{\n\t\t\tX509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,\n\t\t\t\t\t\tX509_R_UNKNOWN_PURPOSE_ID);\n\t\t\treturn 0;\n\t\t\t}\n\t\tptmp = X509_PURPOSE_get0(idx);\n\t\tif (ptmp->trust == X509_TRUST_DEFAULT)\n\t\t\t{\n\t\t\tidx = X509_PURPOSE_get_by_id(def_purpose);\n\t\t\tif (idx == -1)\n\t\t\t\t{\n\t\t\t\tX509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,\n\t\t\t\t\t\tX509_R_UNKNOWN_PURPOSE_ID);\n\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tptmp = X509_PURPOSE_get0(idx);\n\t\t\t}\n\t\tif (!trust) trust = ptmp->trust;\n\t\t}\n\tif (trust)\n\t\t{\n\t\tidx = X509_TRUST_get_by_id(trust);\n\t\tif (idx == -1)\n\t\t\t{\n\t\t\tX509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,\n\t\t\t\t\t\tX509_R_UNKNOWN_TRUST_ID);\n\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\tif (purpose) ctx->purpose = purpose;\n\tif (trust) ctx->trust = trust;\n\treturn 1;\n}', 'int X509_PURPOSE_get_by_id(int purpose)\n{\n\tX509_PURPOSE tmp;\n\tint idx;\n\tif((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))\n\t\treturn purpose - X509_PURPOSE_MIN;\n\ttmp.purpose = purpose;\n\tif(!xptable) return -1;\n\tidx = sk_X509_PURPOSE_find(xptable, &tmp);\n\tif(idx == -1) return -1;\n\treturn idx + X509_PURPOSE_COUNT;\n}', 'X509_PURPOSE * X509_PURPOSE_get0(int idx)\n{\n\tif(idx < 0) return NULL;\n\tif(idx < X509_PURPOSE_COUNT) return xstandard + idx;\n\treturn sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);\n}']