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


crypto/asn1/ameth_lib.c:159:1: start of procedure EVP_PKEY_asn1_find_str()
157.   	}
158.   
159. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(const char *str, int len)
160.   	{
161.   	int i;

crypto/asn1/ameth_lib.c:163:7: 
161.   	int i;
162.   	const EVP_PKEY_ASN1_METHOD *ameth;
163. > 	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
164.   		{
165.   		ameth = EVP_PKEY_asn1_get0(i);

crypto/asn1/ameth_lib.c:163:14: 
161.   	int i;
162.   	const EVP_PKEY_ASN1_METHOD *ameth;
163. > 	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
164.   		{
165.   		ameth = EVP_PKEY_asn1_get0(i);

crypto/asn1/ameth_lib.c:116:1: start of procedure EVP_PKEY_asn1_get_count()
  114.   	}
  115.   
  116. > int EVP_PKEY_asn1_get_count(void)
  117.   	{
  118.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);

crypto/asn1/ameth_lib.c:118:2: 
  116.   int EVP_PKEY_asn1_get_count(void)
  117.   	{
  118. > 	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  119.   	if (app_methods)
  120.   		num += sk_num(app_methods);

crypto/asn1/ameth_lib.c:119:6: Taking false branch
  117.   	{
  118.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  119.   	if (app_methods)
              ^
  120.   		num += sk_num(app_methods);
  121.   	return num;

crypto/asn1/ameth_lib.c:121:2: 
  119.   	if (app_methods)
  120.   		num += sk_num(app_methods);
  121. > 	return num;
  122.   	}
  123.   

crypto/asn1/ameth_lib.c:122:2: return from a call to EVP_PKEY_asn1_get_count
  120.   		num += sk_num(app_methods);
  121.   	return num;
  122.   	}
          ^
  123.   
  124.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)

crypto/asn1/ameth_lib.c:163:14: Loop condition is true. Entering loop body
161.   	int i;
162.   	const EVP_PKEY_ASN1_METHOD *ameth;
163.   	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
                    ^
164.   		{
165.   		ameth = EVP_PKEY_asn1_get0(i);

crypto/asn1/ameth_lib.c:165:3: 
163.   	for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
164.   		{
165. > 		ameth = EVP_PKEY_asn1_get0(i);
166.   		if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
167.   			continue;

crypto/asn1/ameth_lib.c:124:1: start of procedure EVP_PKEY_asn1_get0()
  122.   	}
  123.   
  124. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
  125.   	{
  126.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);

crypto/asn1/ameth_lib.c:126:2: 
  124.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
  125.   	{
  126. > 	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  127.   	if (idx < 0)
  128.   		return NULL; 

crypto/asn1/ameth_lib.c:127:6: Taking false branch
  125.   	{
  126.   	int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
  127.   	if (idx < 0)
              ^
  128.   		return NULL; 
  129.   	if (idx < num)

crypto/asn1/ameth_lib.c:129:6: Taking false branch
  127.   	if (idx < 0)
  128.   		return NULL; 
  129.   	if (idx < num)
              ^
  130.   		return standard_methods[idx];
  131.   	idx -= num;

crypto/asn1/ameth_lib.c:131:2: 
  129.   	if (idx < num)
  130.   		return standard_methods[idx];
  131. > 	idx -= num;
  132.   	return (const EVP_PKEY_ASN1_METHOD *)sk_value(app_methods, idx);
  133.   	}

crypto/asn1/ameth_lib.c:132:2: 
  130.   		return standard_methods[idx];
  131.   	idx -= num;
  132. > 	return (const EVP_PKEY_ASN1_METHOD *)sk_value(app_methods, idx);
  133.   	}
  134.   

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

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

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

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

crypto/asn1/ameth_lib.c:133:2: return from a call to EVP_PKEY_asn1_get0
  131.   	idx -= num;
  132.   	return (const EVP_PKEY_ASN1_METHOD *)sk_value(app_methods, idx);
  133.   	}
          ^
  134.   
  135.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(int type)

crypto/asn1/ameth_lib.c:166:7: 
164.   		{
165.   		ameth = EVP_PKEY_asn1_get0(i);
166. > 		if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
167.   			continue;
168.   		if ((strlen(ameth->pem_str) == len) && 

const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(const char *str, int len)
	{
	int i;
	const EVP_PKEY_ASN1_METHOD *ameth;
	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 ((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(const char *str, int len)\n\t{\n\tint i;\n\tconst EVP_PKEY_ASN1_METHOD *ameth;\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 ((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_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 (const EVP_PKEY_ASN1_METHOD *)sk_value(app_methods, idx);\n\t}', 'char *sk_value(const STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}']