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


crypto/x509/x509_cmp.c:391:1: start of procedure X509_chain_check_suiteb()
389.   }
390.   
391. > int X509_chain_check_suiteb(int *perror_depth, X509 *x, STACK_OF(X509) *chain,
392.                               unsigned long flags)
393.   {

crypto/x509/x509_cmp.c:395:5: 
393.   {
394.       int rv, i, sign_nid;
395. >     EVP_PKEY *pk = NULL;
396.       unsigned long tflags;
397.       if (!(flags & X509_V_FLAG_SUITEB_128_LOS))

crypto/x509/x509_cmp.c:397:11: Taking false branch
395.       EVP_PKEY *pk = NULL;
396.       unsigned long tflags;
397.       if (!(flags & X509_V_FLAG_SUITEB_128_LOS))
                 ^
398.           return X509_V_OK;
399.       tflags = flags;

crypto/x509/x509_cmp.c:399:5: 
397.       if (!(flags & X509_V_FLAG_SUITEB_128_LOS))
398.           return X509_V_OK;
399. >     tflags = flags;
400.       /* If no EE certificate passed in must be first in chain */
401.       if (x == NULL) {

crypto/x509/x509_cmp.c:401:9: Taking true branch
399.       tflags = flags;
400.       /* If no EE certificate passed in must be first in chain */
401.       if (x == NULL) {
               ^
402.           x = sk_X509_value(chain, 0);
403.           i = 1;

crypto/x509/x509_cmp.c:402:13: Condition is true
400.       /* If no EE certificate passed in must be first in chain */
401.       if (x == NULL) {
402.           x = sk_X509_value(chain, 0);
                   ^
403.           i = 1;
404.       } else

crypto/x509/x509_cmp.c:402:9: 
400.       /* If no EE certificate passed in must be first in chain */
401.       if (x == NULL) {
402. >         x = sk_X509_value(chain, 0);
403.           i = 1;
404.       } else

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 false 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:326:17: Taking false 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:326:28: 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)

crypto/x509/x509_cmp.c:403:9: 
401.       if (x == NULL) {
402.           x = sk_X509_value(chain, 0);
403. >         i = 1;
404.       } else
405.           i = 0;

crypto/x509/x509_cmp.c:407:9: 
405.           i = 0;
406.   
407. >     if (X509_get_version(x) != 2) {
408.           rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
409.           /* 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.   
