crypto/x509v3/v3_purp.c:121: error: NULL_DEREFERENCE
  pointer `pt` last assigned on line 120 could be null and is dereferenced at line 121, column 9.
Showing all 35 steps of the trace


crypto/x509v3/v3_purp.c:108:1: start of procedure X509_check_purpose()
106.    * I really can't because it does recalculate hashes and do other non-const
107.    * things. */
108. > int X509_check_purpose(X509 *x, int id, int ca)
109.   {
110.   	int idx;

crypto/x509v3/v3_purp.c:112:7: Taking true branch
110.   	int idx;
111.   	const X509_PURPOSE *pt;
112.   	if(!(x->ex_flags & EXFLAG_SET)) {
             ^
113.   		CRYPTO_w_lock(CRYPTO_LOCK_X509);
114.   		x509v3_cache_extensions(x);

crypto/x509v3/v3_purp.c:113:3: 
111.   	const X509_PURPOSE *pt;
112.   	if(!(x->ex_flags & EXFLAG_SET)) {
113. > 		CRYPTO_w_lock(CRYPTO_LOCK_X509);
114.   		x509v3_cache_extensions(x);
115.   		CRYPTO_w_unlock(CRYPTO_LOCK_X509);

crypto/cryptlib.c:448:1: start of procedure CRYPTO_lock()
  446.   	}
  447.   
  448. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  449.   	{
  450.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:473:6: Taking false branch
  471.   		}
  472.   #endif
  473.   	if (type < 0)
              ^
  474.   		{
  475.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:488:7: Taking true branch
  486.   		}
  487.   	else
  488.   		if (locking_callback != NULL)
               ^
  489.   			locking_callback(mode,type,file,line);
  490.   	}

crypto/cryptlib.c:489:4: Skipping __function_pointer__(): unresolved function pointer
  487.   	else
  488.   		if (locking_callback != NULL)
  489.   			locking_callback(mode,type,file,line);
            ^
  490.   	}
  491.   

crypto/cryptlib.c:473:2: 
  471.   		}
  472.   #endif
  473. > 	if (type < 0)
  474.   		{
  475.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:490:2: return from a call to CRYPTO_lock
  488.   		if (locking_callback != NULL)
  489.   			locking_callback(mode,type,file,line);
  490.   	}
          ^
  491.   
  492.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/x509v3/v3_purp.c:114:3: Skipping x509v3_cache_extensions(): empty list of specs
112.   	if(!(x->ex_flags & EXFLAG_SET)) {
113.   		CRYPTO_w_lock(CRYPTO_LOCK_X509);
114.   		x509v3_cache_extensions(x);
         ^
115.   		CRYPTO_w_unlock(CRYPTO_LOCK_X509);
116.   	}

crypto/x509v3/v3_purp.c:115:3: 
113.   		CRYPTO_w_lock(CRYPTO_LOCK_X509);
114.   		x509v3_cache_extensions(x);
115. > 		CRYPTO_w_unlock(CRYPTO_LOCK_X509);
116.   	}
117.   	if(id == -1) return 1;

crypto/cryptlib.c:448:1: start of procedure CRYPTO_lock()
  446.   	}
  447.   
  448. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  449.   	{
  450.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:473:6: Taking false branch
  471.   		}
  472.   #endif
  473.   	if (type < 0)
              ^
  474.   		{
  475.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:488:7: Taking true branch
  486.   		}
  487.   	else
  488.   		if (locking_callback != NULL)
               ^
  489.   			locking_callback(mode,type,file,line);
  490.   	}

crypto/cryptlib.c:489:4: Skipping __function_pointer__(): unresolved function pointer
  487.   	else
  488.   		if (locking_callback != NULL)
  489.   			locking_callback(mode,type,file,line);
            ^
  490.   	}
  491.   

crypto/cryptlib.c:473:2: 
  471.   		}
  472.   #endif
  473. > 	if (type < 0)
  474.   		{
  475.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:490:2: return from a call to CRYPTO_lock
  488.   		if (locking_callback != NULL)
  489.   			locking_callback(mode,type,file,line);
  490.   	}
          ^
  491.   
  492.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/x509v3/v3_purp.c:117:5: Taking false branch
115.   		CRYPTO_w_unlock(CRYPTO_LOCK_X509);
116.   	}
117.   	if(id == -1) return 1;
           ^
118.   	idx = X509_PURPOSE_get_by_id(id);
119.   	if(idx == -1) return -1;

crypto/x509v3/v3_purp.c:118:2: 
116.   	}
117.   	if(id == -1) return 1;
118. > 	idx = X509_PURPOSE_get_by_id(id);
119.   	if(idx == -1) return -1;
120.   	pt = X509_PURPOSE_get0(idx);

crypto/x509v3/v3_purp.c:158:1: start of procedure X509_PURPOSE_get_by_id()
  156.   }
  157.   
  158. > int X509_PURPOSE_get_by_id(int purpose)
  159.   {
  160.   	X509_PURPOSE tmp;

crypto/x509v3/v3_purp.c:162:6: Taking true branch
  160.   	X509_PURPOSE tmp;
  161.   	int idx;
  162.   	if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
              ^
  163.   		return purpose - X509_PURPOSE_MIN;
  164.   	tmp.purpose = purpose;

crypto/x509v3/v3_purp.c:162:39: Taking false branch
  160.   	X509_PURPOSE tmp;
  161.   	int idx;
  162.   	if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
                                               ^
  163.   		return purpose - X509_PURPOSE_MIN;
  164.   	tmp.purpose = purpose;

crypto/x509v3/v3_purp.c:164:2: 
  162.   	if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
  163.   		return purpose - X509_PURPOSE_MIN;
  164. > 	tmp.purpose = purpose;
  165.   	if(!xptable) return -1;
  166.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);

crypto/x509v3/v3_purp.c:165:6: Taking false branch
  163.   		return purpose - X509_PURPOSE_MIN;
  164.   	tmp.purpose = purpose;
  165.   	if(!xptable) return -1;
              ^
  166.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);
  167.   	if(idx == -1) return -1;

crypto/x509v3/v3_purp.c:166:2: Skipping sk_find(): empty list of specs
  164.   	tmp.purpose = purpose;
  165.   	if(!xptable) return -1;
  166.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);
          ^
  167.   	if(idx == -1) return -1;
  168.   	return idx + X509_PURPOSE_COUNT;

crypto/x509v3/v3_purp.c:167:5: Taking false branch
  165.   	if(!xptable) return -1;
  166.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);
  167.   	if(idx == -1) return -1;
             ^
  168.   	return idx + X509_PURPOSE_COUNT;
  169.   }

crypto/x509v3/v3_purp.c:168:2: 
  166.   	idx = sk_X509_PURPOSE_find(xptable, &tmp);
  167.   	if(idx == -1) return -1;
  168. > 	return idx + X509_PURPOSE_COUNT;
  169.   }
  170.   

crypto/x509v3/v3_purp.c:169:1: return from a call to X509_PURPOSE_get_by_id
  167.   	if(idx == -1) return -1;
  168.   	return idx + X509_PURPOSE_COUNT;
  169. > }
  170.   
  171.   int X509_PURPOSE_add(int id, int trust, int flags,

crypto/x509v3/v3_purp.c:119:5: Taking false branch
117.   	if(id == -1) return 1;
118.   	idx = X509_PURPOSE_get_by_id(id);
119.   	if(idx == -1) return -1;
           ^
120.   	pt = X509_PURPOSE_get0(idx);
121.   	return pt->check_purpose(pt, x, ca);

crypto/x509v3/v3_purp.c:120:2: 
118.   	idx = X509_PURPOSE_get_by_id(id);
119.   	if(idx == -1) return -1;
120. > 	pt = X509_PURPOSE_get0(idx);
121.   	return pt->check_purpose(pt, x, ca);
122.   }

crypto/x509v3/v3_purp.c:140:1: start of procedure X509_PURPOSE_get0()
  138.   }
  139.   
  140. > X509_PURPOSE * X509_PURPOSE_get0(int idx)
  141.   {
  142.   	if(idx < 0) return NULL;

crypto/x509v3/v3_purp.c:142:5: Taking true branch
  140.   X509_PURPOSE * X509_PURPOSE_get0(int idx)
  141.   {
  142.   	if(idx < 0) return NULL;
             ^
  143.   	if(idx < X509_PURPOSE_COUNT) return xstandard + idx;
  144.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);

crypto/x509v3/v3_purp.c:142:14: 
  140.   X509_PURPOSE * X509_PURPOSE_get0(int idx)
  141.   {
  142. > 	if(idx < 0) return NULL;
  143.   	if(idx < X509_PURPOSE_COUNT) return xstandard + idx;
  144.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);

crypto/x509v3/v3_purp.c:145:1: return from a call to X509_PURPOSE_get0
  143.   	if(idx < X509_PURPOSE_COUNT) return xstandard + idx;
  144.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  145. > }
  146.   
  147.   int X509_PURPOSE_get_by_sname(char *sname)

crypto/x509v3/v3_purp.c:121:2: 
119.   	if(idx == -1) return -1;
120.   	pt = X509_PURPOSE_get0(idx);
121. > 	return pt->check_purpose(pt, x, ca);
122.   }
123.   

int X509_check_purpose(X509 *x, int id, int ca)
{
	int idx;
	const X509_PURPOSE *pt;
	if(!(x->ex_flags & EXFLAG_SET)) {
		CRYPTO_w_lock(CRYPTO_LOCK_X509);
		x509v3_cache_extensions(x);
		CRYPTO_w_unlock(CRYPTO_LOCK_X509);
	}
	if(id == -1) return 1;
	idx = X509_PURPOSE_get_by_id(id);
	if(idx == -1) return -1;
	pt = X509_PURPOSE_get0(idx);
	return pt->check_purpose(pt, x, ca);
}
['int X509_check_purpose(X509 *x, int id, int ca)\n{\n\tint idx;\n\tconst X509_PURPOSE *pt;\n\tif(!(x->ex_flags & EXFLAG_SET)) {\n\t\tCRYPTO_w_lock(CRYPTO_LOCK_X509);\n\t\tx509v3_cache_extensions(x);\n\t\tCRYPTO_w_unlock(CRYPTO_LOCK_X509);\n\t}\n\tif(id == -1) return 1;\n\tidx = X509_PURPOSE_get_by_id(id);\n\tif(idx == -1) return -1;\n\tpt = X509_PURPOSE_get0(idx);\n\treturn pt->check_purpose(pt, x, ca);\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n\t{\n#ifdef LOCK_DEBUG\n\t\t{\n\t\tchar *rw_text,*operation_text;\n\t\tif (mode & CRYPTO_LOCK)\n\t\t\toperation_text="lock  ";\n\t\telse if (mode & CRYPTO_UNLOCK)\n\t\t\toperation_text="unlock";\n\t\telse\n\t\t\toperation_text="ERROR ";\n\t\tif (mode & CRYPTO_READ)\n\t\t\trw_text="r";\n\t\telse if (mode & CRYPTO_WRITE)\n\t\t\trw_text="w";\n\t\telse\n\t\t\trw_text="ERROR";\n\t\tfprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\\n",\n\t\t\tCRYPTO_thread_id(), rw_text, operation_text,\n\t\t\tCRYPTO_get_lock_name(type), file, line);\n\t\t}\n#endif\n\tif (type < 0)\n\t\t{\n\t\tif (dynlock_lock_callback != NULL)\n\t\t\t{\n\t\t\tstruct CRYPTO_dynlock_value *pointer\n\t\t\t\t= CRYPTO_get_dynlock_value(type);\n\t\t\tOPENSSL_assert(pointer != NULL);\n\t\t\tdynlock_lock_callback(mode, pointer, file, line);\n\t\t\tCRYPTO_destroy_dynlockid(type);\n\t\t\t}\n\t\t}\n\telse\n\t\tif (locking_callback != NULL)\n\t\t\tlocking_callback(mode,type,file,line);\n\t}', '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}']