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


crypto/asn1/ameth_lib.c:202:1: start of procedure EVP_PKEY_asn1_find_str()
200.   	}
201.   
202. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
203.   					const char *str, int len)
204.   	{

crypto/asn1/ameth_lib.c:207:6: Taking true branch
205.   	int i;
206.   	const EVP_PKEY_ASN1_METHOD *ameth;
207.   	if (len == -1)
            ^
208.   		len = strlen(str);
209.   	if (pe)

crypto/asn1/ameth_lib.c:208:3: 
206.   	const EVP_PKEY_ASN1_METHOD *ameth;
207.   	if (len == -1)
208. > 		len = strlen(str);
209.   	if (pe)
210.   		{

crypto/asn1/ameth_lib.c:209:6: Taking false branch
207.   	if (len == -1)
208.   		len = strlen(str);
209.   	if (pe)
            ^
210.   		{
211.   #ifndef OPENSSL_NO_ENGINE

crypto/asn1/ameth_lib.c:228:7: 
226.   		*pe = NULL;
227.   		}
228. > 	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
229.   		{
230.   		ameth = EVP_PKEY_asn1_get0(i);

crypto/asn1/ameth_lib.c:228:14: 
226.   		*pe = NULL;
227.   		}
228. > 	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
229.   		{
230.   		ameth = EVP_PKEY_asn1_get0(i);

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

crypto/asn1/ameth_lib.c:131:2: 
  129.   int EVP_PKEY_asn1_get_count(void)
  130.   	{
  131. > 	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  132.   	if (app_methods)
  133.   		num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);

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

crypto/asn1/ameth_lib.c:134:2: 
  132.   	if (app_methods)
  133.   		num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
  134. > 	return num;
  135.   	}
  136.   

crypto/asn1/ameth_lib.c:135:2: return from a call to EVP_PKEY_asn1_get_count
  133.   		num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
  134.   	return num;
  135.   	}
          ^
  136.   
  137.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)

crypto/asn1/ameth_lib.c:228:14: Loop condition is true. Entering loop body
226.   		*pe = NULL;
227.   		}
228.   	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
                    ^
229.   		{
230.   		ameth = EVP_PKEY_asn1_get0(i);

crypto/asn1/ameth_lib.c:230:3: 
228.   	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
229.   		{
230. > 		ameth = EVP_PKEY_asn1_get0(i);
231.   		if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
232.   			continue;

crypto/asn1/ameth_lib.c:137:1: start of procedure EVP_PKEY_asn1_get0()
  135.   	}
  136.   
  137. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
  138.   	{
  139.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);

crypto/asn1/ameth_lib.c:139:2: 
  137.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
  138.   	{
  139. > 	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  140.   	if (idx < 0)
  141.   		return NULL; 

crypto/asn1/ameth_lib.c:140:6: Taking false branch
  138.   	{
  139.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  140.   	if (idx < 0)
              ^
  141.   		return NULL; 
  142.   	if (idx < num)

crypto/asn1/ameth_lib.c:142:6: Taking false branch
  140.   	if (idx < 0)
  141.   		return NULL; 
  142.   	if (idx < num)
              ^
  143.   		return standard_methods[idx];
  144.   	idx -= num;

crypto/asn1/ameth_lib.c:144:2: 
  142.   	if (idx < num)
  143.   		return standard_methods[idx];
  144. > 	idx -= num;
  145.   	return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  146.   	}

crypto/asn1/ameth_lib.c:145:9: Condition is true
  143.   		return standard_methods[idx];
  144.   	idx -= num;
  145.   	return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
                 ^
  146.   	}
  147.   

crypto/asn1/ameth_lib.c:145:2: 
  143.   		return standard_methods[idx];
  144.   	idx -= num;
  145. > 	return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  146.   	}
  147.   

crypto/stack/stack.c:300:1: start of procedure sk_value()
    298.   }
    299.   
    300. > void *sk_value(const _STACK *st, int i)
    301.   {
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:302:6: Taking true branch
    300.   void *sk_value(const _STACK *st, int i)
    301.   {
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                ^
    303.   	return st->data[i];
    304.   }

crypto/stack/stack.c:302:39: 
    300.   void *sk_value(const _STACK *st, int i)
    301.   {
    302. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
    303.   	return st->data[i];
    304.   }

crypto/stack/stack.c:304:1: return from a call to sk_value
    302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
    303.   	return st->data[i];
    304. > }
    305.   
    306.   void *sk_set(_STACK *st, int i, void *value)

crypto/asn1/ameth_lib.c:146:2: return from a call to EVP_PKEY_asn1_get0
  144.   	idx -= num;
  145.   	return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  146.   	}
          ^
  147.   
  148.   static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)

crypto/asn1/ameth_lib.c:231:7: 
229.   		{
230.   		ameth = EVP_PKEY_asn1_get0(i);
231. > 		if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
232.   			continue;
233.   		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}']