crypto/x509/x509_cmp.c:413: error: NULL_DEREFERENCE
  pointer `x` last assigned on line 408 could be null and is dereferenced by call to `X509_get_version()` at line 413, column 9.
Showing all 16 steps of the trace


crypto/x509/x509_cmp.c:397:1: start of procedure X509_chain_check_suiteb()
395.   }
396.   
397. > int X509_chain_check_suiteb(int *perror_depth, X509 *x, STACK_OF(X509) *chain,
398.                               unsigned long flags)
399.   {

crypto/x509/x509_cmp.c:401:5: 
399.   {
400.       int rv, i, sign_nid;
401. >     EVP_PKEY *pk = NULL;
402.       unsigned long tflags;
403.       if (!(flags & X509_V_FLAG_SUITEB_128_LOS))

crypto/x509/x509_cmp.c:403:11: Taking false branch
401.       EVP_PKEY *pk = NULL;
402.       unsigned long tflags;
403.       if (!(flags & X509_V_FLAG_SUITEB_128_LOS))
                 ^
404.           return X509_V_OK;
405.       tflags = flags;

crypto/x509/x509_cmp.c:405:5: 
403.       if (!(flags & X509_V_FLAG_SUITEB_128_LOS))
404.           return X509_V_OK;
405. >     tflags = flags;
406.       /* If no EE certificate passed in must be first in chain */
407.       if (x == NULL) {

crypto/x509/x509_cmp.c:407:9: Taking true branch
405.       tflags = flags;
406.       /* If no EE certificate passed in must be first in chain */
407.       if (x == NULL) {
               ^
408.           x = sk_X509_value(chain, 0);
409.           i = 1;

crypto/x509/x509_cmp.c:408:9: 
406.       /* If no EE certificate passed in must be first in chain */
407.       if (x == NULL) {
408. >         x = sk_X509_value(chain, 0);
409.           i = 1;
410.       } else

include/openssl/x509.h:170:1: start of procedure sk_X509_value()
  168.   typedef struct x509_cinf_st X509_CINF;
  169.   
  170. > DEFINE_STACK_OF(X509)
  171.   
  172.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:324:1: start of procedure sk_value()
    322.   }
    323.   
    324. > void *sk_value(const _STACK *st, int i)
    325.   {
    326.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:326:10: Taking true branch
    324.   void *sk_value(const _STACK *st, int i)
    325.   {
    326.       if (!st || (i < 0) || (i >= st->num))
                    ^
    327.           return NULL;
    328.       return st->data[i];

crypto/stack/stack.c:327:9: 
    325.   {
    326.       if (!st || (i < 0) || (i >= st->num))
    327. >         return NULL;
    328.       return st->data[i];
    329.   }

crypto/stack/stack.c:329:1: return from a call to sk_value
    327.           return NULL;
    328.       return st->data[i];
    329. > }
    330.   
    331.   void *sk_set(_STACK *st, int i, void *value)

include/openssl/x509.h:170:1: return from a call to sk_X509_value
  168.   typedef struct x509_cinf_st X509_CINF;
  169.   
  170. > DEFINE_STACK_OF(X509)
  171.   
  172.   /* This is used for a table of trust checking functions */

crypto/x509/x509_cmp.c:409:9: 
407.       if (x == NULL) {
408.           x = sk_X509_value(chain, 0);
409. >         i = 1;
410.       } else
411.           i = 0;

crypto/x509/x509_cmp.c:413:9: 
411.           i = 0;
412.   
413. >     if (X509_get_version(x) != 2) {
414.           rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
415.           /* Correct error depth */

crypto/x509/x509_set.c:155:1: start of procedure X509_get_version()
  153.   }
  154.   
  155. > long X509_get_version(X509 *x)
  156.   {
  157.       return ASN1_INTEGER_get(x->cert_info.version);

crypto/x509/x509_set.c:157:5: 
  155.   long X509_get_version(X509 *x)
  156.   {
  157. >     return ASN1_INTEGER_get(x->cert_info.version);
  158.   }
  159.   
