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


crypto/x509/x509_vfy.c:802:1: start of procedure X509_STORE_CTX_purpose_inherit()
800.    */
801.   
802. > int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
803.   				int purpose, int trust)
804.   {

crypto/x509/x509_vfy.c:807:7: Taking false branch
805.   	int idx;
806.   	/* If purpose not set use default */
807.   	if (!purpose) purpose = def_purpose;
             ^
808.   	/* If we have a purpose then check it is valid */
809.   	if (purpose)

crypto/x509/x509_vfy.c:809:6: Taking true branch
807.   	if (!purpose) purpose = def_purpose;
808.   	/* If we have a purpose then check it is valid */
809.   	if (purpose)
            ^
810.   		{
811.   		X509_PURPOSE *ptmp;

crypto/x509/x509_vfy.c:812:3: 
810.   		{
811.   		X509_PURPOSE *ptmp;
812. > 		idx = X509_PURPOSE_get_by_id(purpose);
813.   		if (idx == -1)
814.   			{

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:813:7: Taking false branch
811.   		X509_PURPOSE *ptmp;
812.   		idx = X509_PURPOSE_get_by_id(purpose);
813.   		if (idx == -1)
             ^
814.   			{
815.   			X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,

crypto/x509/x509_vfy.c:819:3: 
817.   			return 0;
818.   			}
819. > 		ptmp = X509_PURPOSE_get0(idx);
820.   		if (ptmp->trust == X509_TRUST_DEFAULT)
821.   			{

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

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

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

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

crypto/x509/x509_vfy.c:820:7: 
818.   			}
819.   		ptmp = X509_PURPOSE_get0(idx);
820. > 		if (ptmp->trust == X509_TRUST_DEFAULT)
821.   			{
822.   			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}']