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


crypto/x509/x509_vfy.c:766:1: start of procedure X509_STORE_CTX_purpose_inherit()
764.    */
765.   
766. > int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
767.   				int purpose, int trust)
768.   {

crypto/x509/x509_vfy.c:771:6: Taking false branch
769.   	int idx;
770.   	/* If purpose not set use default */
771.   	if(!purpose) purpose = def_purpose;
            ^
772.   	/* If we have a purpose then check it is valid */
773.   	if(purpose) {

crypto/x509/x509_vfy.c:773:5: Taking true branch
771.   	if(!purpose) purpose = def_purpose;
772.   	/* If we have a purpose then check it is valid */
773.   	if(purpose) {
           ^
774.   		X509_PURPOSE *ptmp;
775.   		idx = X509_PURPOSE_get_by_id(purpose);

crypto/x509/x509_vfy.c:775:3: 
773.   	if(purpose) {
774.   		X509_PURPOSE *ptmp;
775. > 		idx = X509_PURPOSE_get_by_id(purpose);
776.   		if(idx == -1) {
777.   			X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,

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

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

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

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

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

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

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

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

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

crypto/x509/x509_vfy.c:776:6: Taking false branch
774.   		X509_PURPOSE *ptmp;
775.   		idx = X509_PURPOSE_get_by_id(purpose);
776.   		if(idx == -1) {
            ^
777.   			X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT,
778.   						X509_R_UNKNOWN_PURPOSE_ID);

crypto/x509/x509_vfy.c:781:3: 
779.   			return 0;
780.   		}
781. > 		ptmp = X509_PURPOSE_get0(idx);
782.   		if(ptmp->trust == X509_TRUST_DEFAULT) {
783.   			idx = X509_PURPOSE_get_by_id(def_purpose);

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

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

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

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

crypto/x509/x509_vfy.c:782:6: 
780.   		}
781.   		ptmp = X509_PURPOSE_get0(idx);
782. > 		if(ptmp->trust == X509_TRUST_DEFAULT) {
783.   			idx = X509_PURPOSE_get_by_id(def_purpose);
784.   			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}']