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


crypto/x509/x509_vfy.c:756:1: start of procedure X509_STORE_CTX_purpose_inherit()
754.    */
755.   
756. > int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
757.   				int purpose, int trust)
758.   {

crypto/x509/x509_vfy.c:761:6: Taking false branch
759.   	int idx;
760.   	/* If purpose not set use default */
761.   	if(!purpose) purpose = def_purpose;
            ^
762.   	/* If we have a purpose then check it is valid */
763.   	if(purpose) {

crypto/x509/x509_vfy.c:763:5: Taking true branch
761.   	if(!purpose) purpose = def_purpose;
762.   	/* If we have a purpose then check it is valid */
763.   	if(purpose) {
           ^
764.   		X509_PURPOSE *ptmp;
765.   		idx = X509_PURPOSE_get_by_id(purpose);

crypto/x509/x509_vfy.c:765:3: 
763.   	if(purpose) {
764.   		X509_PURPOSE *ptmp;
765. > 		idx = X509_PURPOSE_get_by_id(purpose);
766.   		if(idx == -1) {
767.   			X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,

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:766:6: Taking false branch
764.   		X509_PURPOSE *ptmp;
765.   		idx = X509_PURPOSE_get_by_id(purpose);
766.   		if(idx == -1) {
            ^
767.   			X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
768.   						X509_R_UNKNOWN_PURPOSE_ID);

crypto/x509/x509_vfy.c:771:3: 
769.   			return 0;
770.   		}
771. > 		ptmp = X509_PURPOSE_get0(idx);
772.   		if(ptmp->trust == X509_TRUST_DEFAULT) {
773.   			idx = X509_PURPOSE_get_by_id(def_purpose);

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:772:6: 
770.   		}
771.   		ptmp = X509_PURPOSE_get0(idx);
772. > 		if(ptmp->trust == X509_TRUST_DEFAULT) {
773.   			idx = X509_PURPOSE_get_by_id(def_purpose);
774.   			if(idx == -1) {

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\tX509_PURPOSE *ptmp;\n\t\tidx = X509_PURPOSE_get_by_id(purpose);\n\t\tif(idx == -1) {\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}\n\t\tptmp = X509_PURPOSE_get0(idx);\n\t\tif(ptmp->trust == X509_TRUST_DEFAULT) {\n\t\t\tidx = X509_PURPOSE_get_by_id(def_purpose);\n\t\t\tif(idx == -1) {\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}\n\t\t\tptmp = X509_PURPOSE_get0(idx);\n\t\t}\n\t\tif(!trust) trust = ptmp->trust;\n\t}\n\tif(trust) {\n\t\tidx = X509_TRUST_get_by_id(trust);\n\t\tif(idx == -1) {\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}\n\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}']