ssl/s3_both.c:423: error: NULL_DEREFERENCE
  pointer `pk` last assigned on line 383 could be null and is dereferenced by call to `EVP_PKEY_free()` at line 423, column 12.
Showing all 20 steps of the trace


ssl/s3_both.c:377:1: start of procedure ssl_cert_type()
375.   	}
376.   
377. > int ssl_cert_type(X509 *x, EVP_PKEY *pkey)
378.   	{
379.   	EVP_PKEY *pk;

ssl/s3_both.c:380:2: 
378.   	{
379.   	EVP_PKEY *pk;
380. > 	int ret= -1,i,j;
381.   
382.   	if (pkey == NULL)

ssl/s3_both.c:382:6: Taking true branch
380.   	int ret= -1,i,j;
381.   
382.   	if (pkey == NULL)
            ^
383.   		pk=X509_get_pubkey(x);
384.   	else

ssl/s3_both.c:383:3: 
381.   
382.   	if (pkey == NULL)
383. > 		pk=X509_get_pubkey(x);
384.   	else
385.   		pk=pkey;

crypto/x509/x509_cmp.c:250:1: start of procedure X509_get_pubkey()
  248.   	}
  249.   
  250. > EVP_PKEY *X509_get_pubkey(X509 *x)
  251.   	{
  252.   	if ((x == NULL) || (x->cert_info == NULL))

crypto/x509/x509_cmp.c:252:7: Taking false branch
  250.   EVP_PKEY *X509_get_pubkey(X509 *x)
  251.   	{
  252.   	if ((x == NULL) || (x->cert_info == NULL))
               ^
  253.   		return(NULL);
  254.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:252:22: Taking true branch
  250.   EVP_PKEY *X509_get_pubkey(X509 *x)
  251.   	{
  252.   	if ((x == NULL) || (x->cert_info == NULL))
                              ^
  253.   		return(NULL);
  254.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:253:3: 
  251.   	{
  252.   	if ((x == NULL) || (x->cert_info == NULL))
  253. > 		return(NULL);
  254.   	return(X509_PUBKEY_get(x->cert_info->key));
  255.   	}

crypto/x509/x509_cmp.c:255:2: return from a call to X509_get_pubkey
  253.   		return(NULL);
  254.   	return(X509_PUBKEY_get(x->cert_info->key));
  255.   	}
          ^
  256.   
  257.   int X509_check_private_key(X509 *x, EVP_PKEY *k)

ssl/s3_both.c:386:6: Taking true branch
384.   	else
385.   		pk=pkey;
386.   	if (pk == NULL) goto err;
            ^
387.   
388.   	i=pk->type;

ssl/s3_both.c:422:1: 
420.   		ret= -1;
421.   
422. > err:
423.   	if(!pkey) EVP_PKEY_free(pk);
424.   	return(ret);

ssl/s3_both.c:423:6: Taking true branch
421.   
422.   err:
423.   	if(!pkey) EVP_PKEY_free(pk);
            ^
424.   	return(ret);
425.   	}

ssl/s3_both.c:423:12: 
421.   
422.   err:
423. > 	if(!pkey) EVP_PKEY_free(pk);
424.   	return(ret);
425.   	}

crypto/evp/p_lib.c:286:1: start of procedure EVP_PKEY_free()
  284.   	}
  285.   
  286. > void EVP_PKEY_free(EVP_PKEY *x)
  287.   	{
  288.   	int i;

crypto/evp/p_lib.c:290:6: Taking false branch
  288.   	int i;
  289.   
  290.   	if (x == NULL) return;
              ^
  291.   
  292.   	i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY);

crypto/evp/p_lib.c:292:2: 
  290.   	if (x == NULL) return;
  291.   
  292. > 	i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY);
  293.   #ifdef REF_PRINT
  294.   	REF_PRINT("EVP_PKEY",x);

crypto/cryptlib.c:226:1: start of procedure CRYPTO_add_lock()
    224.   	}
    225.   
    226. > int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
    227.   	     int line)
    228.   	{

crypto/cryptlib.c:231:6: Taking true branch
    229.   	int ret;
    230.   
    231.   	if (add_lock_callback != NULL)
                ^
    232.   		{
    233.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:237:3: Skipping __function_pointer__(): unresolved function pointer
    235.   #endif
    236.   
    237.   		ret=add_lock_callback(pointer,amount,type,file,line);
             ^
    238.   #ifdef LOCK_DEBUG
    239.   		fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",

crypto/cryptlib.c:245:3: 
    243.   			file,line);
    244.   #endif
    245. > 		*pointer=ret;
    246.   		}
    247.   	else
