crypto/asn1/ameth_lib.c:224: error: NULL_DEREFERENCE
  pointer `ameth` last assigned on line 223 could be null and is dereferenced at line 224, column 7.
Showing all 26 steps of the trace


crypto/asn1/ameth_lib.c:195:1: start of procedure EVP_PKEY_asn1_find_str()
193.   	}
194.   
195. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
196.   					const char *str, int len)
197.   	{

crypto/asn1/ameth_lib.c:200:6: Taking true branch
198.   	int i;
199.   	const EVP_PKEY_ASN1_METHOD *ameth;
200.   	if (len == -1)
            ^
201.   		len = strlen(str);
202.   	if (pe)

crypto/asn1/ameth_lib.c:201:3: 
199.   	const EVP_PKEY_ASN1_METHOD *ameth;
200.   	if (len == -1)
201. > 		len = strlen(str);
202.   	if (pe)
203.   		{

crypto/asn1/ameth_lib.c:202:6: Taking false branch
200.   	if (len == -1)
201.   		len = strlen(str);
202.   	if (pe)
            ^
203.   		{
204.   #ifndef OPENSSL_NO_ENGINE

crypto/asn1/ameth_lib.c:221:7: 
219.   		*pe = NULL;
220.   		}
221. > 	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
222.   		{
223.   		ameth = EVP_PKEY_asn1_get0(i);

crypto/asn1/ameth_lib.c:221:14: 
219.   		*pe = NULL;
220.   		}
221. > 	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
222.   		{
223.   		ameth = EVP_PKEY_asn1_get0(i);

crypto/asn1/ameth_lib.c:121:1: start of procedure EVP_PKEY_asn1_get_count()
  119.   	}
  120.   
  121. > int EVP_PKEY_asn1_get_count(void)
  122.   	{
  123.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);

crypto/asn1/ameth_lib.c:123:2: 
  121.   int EVP_PKEY_asn1_get_count(void)
  122.   	{
  123. > 	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  124.   	if (app_methods)
  125.   		num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);

crypto/asn1/ameth_lib.c:124:6: Taking false branch
  122.   	{
  123.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  124.   	if (app_methods)
              ^
  125.   		num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
  126.   	return num;

crypto/asn1/ameth_lib.c:126:2: 
  124.   	if (app_methods)
  125.   		num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
  126. > 	return num;
  127.   	}
  128.   

crypto/asn1/ameth_lib.c:127:2: return from a call to EVP_PKEY_asn1_get_count
  125.   		num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
  126.   	return num;
  127.   	}
          ^
  128.   
  129.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)

crypto/asn1/ameth_lib.c:221:14: Loop condition is true. Entering loop body
219.   		*pe = NULL;
220.   		}
221.   	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
                    ^
222.   		{
223.   		ameth = EVP_PKEY_asn1_get0(i);

crypto/asn1/ameth_lib.c:223:3: 
221.   	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
222.   		{
223. > 		ameth = EVP_PKEY_asn1_get0(i);
224.   		if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
225.   			continue;

crypto/asn1/ameth_lib.c:129:1: start of procedure EVP_PKEY_asn1_get0()
  127.   	}
  128.   
  129. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
  130.   	{
  131.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);

crypto/asn1/ameth_lib.c:131:2: 
  129.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
  130.   	{
  131. > 	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  132.   	if (idx < 0)
  133.   		return NULL; 

crypto/asn1/ameth_lib.c:132:6: Taking false branch
  130.   	{
  131.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  132.   	if (idx < 0)
              ^
  133.   		return NULL; 
  134.   	if (idx < num)

crypto/asn1/ameth_lib.c:134:6: Taking false branch
  132.   	if (idx < 0)
  133.   		return NULL; 
  134.   	if (idx < num)
              ^
  135.   		return standard_methods[idx];
  136.   	idx -= num;

crypto/asn1/ameth_lib.c:136:2: 
  134.   	if (idx < num)
  135.   		return standard_methods[idx];
  136. > 	idx -= num;
  137.   	return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  138.   	}

crypto/asn1/ameth_lib.c:137:9: Condition is true
  135.   		return standard_methods[idx];
  136.   	idx -= num;
  137.   	return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
                 ^
  138.   	}
  139.   

crypto/asn1/ameth_lib.c:137:2: 
  135.   		return standard_methods[idx];
  136.   	idx -= num;
  137. > 	return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  138.   	}
  139.   

crypto/stack/stack.c:308:1: start of procedure sk_value()
    306.   }
    307.   
    308. > void *sk_value(const _STACK *st, int i)
    309.   {
    310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:310:6: Taking true branch
    308.   void *sk_value(const _STACK *st, int i)
    309.   {
    310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                ^
    311.   	return st->data[i];
    312.   }

crypto/stack/stack.c:310:39: 
    308.   void *sk_value(const _STACK *st, int i)
    309.   {
    310. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
    311.   	return st->data[i];
    312.   }

crypto/stack/stack.c:312:1: return from a call to sk_value
    310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
    311.   	return st->data[i];
    312. > }
    313.   
    314.   void *sk_set(_STACK *st, int i, void *value)

crypto/asn1/ameth_lib.c:138:2: return from a call to EVP_PKEY_asn1_get0
  136.   	idx -= num;
  137.   	return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  138.   	}
          ^
  139.   
  140.   static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)

crypto/asn1/ameth_lib.c:224:7: 
222.   		{
223.   		ameth = EVP_PKEY_asn1_get0(i);
224. > 		if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
225.   			continue;
226.   		if (((int)strlen(ameth->pem_str) == len) && 

const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
					const char *str, int len)
	{
	int i;
	const EVP_PKEY_ASN1_METHOD *ameth;
	if (len == -1)
		len = strlen(str);
	if (pe)
		{
#ifndef OPENSSL_NO_ENGINE
		ENGINE *e;
		ameth = ENGINE_pkey_asn1_find_str(&e, str, len);
		if (ameth)
			{
			if (!ENGINE_init(e))
				ameth = NULL;
			ENGINE_free(e);
			*pe = e;
			return ameth;
			}
#endif
		*pe = NULL;
		}
	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
		{
		ameth = EVP_PKEY_asn1_get0(i);
		if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
			continue;
		if (((int)strlen(ameth->pem_str) == len) &&
			!strncasecmp(ameth->pem_str, str, len))
			return ameth;
		}
	return NULL;
	}
['const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,\n\t\t\t\t\tconst char *str, int len)\n\t{\n\tint i;\n\tconst EVP_PKEY_ASN1_METHOD *ameth;\n\tif (len == -1)\n\t\tlen = strlen(str);\n\tif (pe)\n\t\t{\n#ifndef OPENSSL_NO_ENGINE\n\t\tENGINE *e;\n\t\tameth = ENGINE_pkey_asn1_find_str(&e, str, len);\n\t\tif (ameth)\n\t\t\t{\n\t\t\tif (!ENGINE_init(e))\n\t\t\t\tameth = NULL;\n\t\t\tENGINE_free(e);\n\t\t\t*pe = e;\n\t\t\treturn ameth;\n\t\t\t}\n#endif\n\t\t*pe = NULL;\n\t\t}\n\tfor (i = 0; i < EVP_PKEY_asn1_get_count(); i++)\n\t\t{\n\t\tameth = EVP_PKEY_asn1_get0(i);\n\t\tif (ameth->pkey_flags & ASN1_PKEY_ALIAS)\n\t\t\tcontinue;\n\t\tif (((int)strlen(ameth->pem_str) == len) &&\n\t\t\t!strncasecmp(ameth->pem_str, str, len))\n\t\t\treturn ameth;\n\t\t}\n\treturn NULL;\n\t}', 'int EVP_PKEY_asn1_get_count(void)\n\t{\n\tint num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);\n\tif (app_methods)\n\t\tnum += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);\n\treturn num;\n\t}', 'const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)\n\t{\n\tint num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);\n\tif (idx < 0)\n\t\treturn NULL;\n\tif (idx < num)\n\t\treturn standard_methods[idx];\n\tidx -= num;\n\treturn sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);\n\t}', 'void *sk_value(const _STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}']