crypto/x509/x509_vfy.c:1557: error: NULL_DEREFERENCE
  pointer `xs` last assigned on line 1541 could be null and is dereferenced at line 1557, column 14.
Showing all 35 steps of the trace


crypto/x509/x509_vfy.c:1513:1: start of procedure internal_verify()
1511.   }
1512.   
1513. > static int internal_verify(X509_STORE_CTX *ctx)
1514.   {
1515.       int ok = 0, n;

crypto/x509/x509_vfy.c:1515:5: 
1513.   static int internal_verify(X509_STORE_CTX *ctx)
1514.   {
1515. >     int ok = 0, n;
1516.       X509 *xs, *xi;
1517.       EVP_PKEY *pkey = NULL;

crypto/x509/x509_vfy.c:1517:5: 
1515.       int ok = 0, n;
1516.       X509 *xs, *xi;
1517. >     EVP_PKEY *pkey = NULL;
1518.       int (*cb) (int xok, X509_STORE_CTX *xctx);
1519.   

crypto/x509/x509_vfy.c:1520:5: 
1518.       int (*cb) (int xok, X509_STORE_CTX *xctx);
1519.   
1520. >     cb = ctx->verify_cb;
1521.   
1522.       n = sk_X509_num(ctx->chain) - 1;

crypto/x509/x509_vfy.c:1522:9: Condition is true
1520.       cb = ctx->verify_cb;
1521.   
1522.       n = sk_X509_num(ctx->chain) - 1;
                ^
1523.       ctx->error_depth = n;
1524.       xi = sk_X509_value(ctx->chain, n);

crypto/x509/x509_vfy.c:1522:5: 
1520.       cb = ctx->verify_cb;
1521.   
1522. >     n = sk_X509_num(ctx->chain) - 1;
1523.       ctx->error_depth = n;
1524.       xi = sk_X509_value(ctx->chain, n);

crypto/stack/stack.c:317:1: start of procedure sk_num()
  315.   }
  316.   
  317. > int sk_num(const _STACK *st)
  318.   {
  319.       if (st == NULL)

crypto/stack/stack.c:319:9: Taking false branch
  317.   int sk_num(const _STACK *st)
  318.   {
  319.       if (st == NULL)
                 ^
  320.           return -1;
  321.       return st->num;

crypto/stack/stack.c:321:5: 
  319.       if (st == NULL)
  320.           return -1;
  321. >     return st->num;
  322.   }
  323.   

crypto/stack/stack.c:322:1: return from a call to sk_num
  320.           return -1;
  321.       return st->num;
  322. > }
  323.   
  324.   void *sk_value(const _STACK *st, int i)

crypto/x509/x509_vfy.c:1523:5: 
1521.   
1522.       n = sk_X509_num(ctx->chain) - 1;
1523. >     ctx->error_depth = n;
1524.       xi = sk_X509_value(ctx->chain, n);
1525.   

crypto/x509/x509_vfy.c:1524:10: Condition is true
1522.       n = sk_X509_num(ctx->chain) - 1;
1523.       ctx->error_depth = n;
1524.       xi = sk_X509_value(ctx->chain, n);
                 ^
1525.   
1526.       if (ctx->check_issued(ctx, xi, xi))

crypto/x509/x509_vfy.c:1524:5: 
1522.       n = sk_X509_num(ctx->chain) - 1;
1523.       ctx->error_depth = n;
1524. >     xi = sk_X509_value(ctx->chain, n);
1525.   
1526.       if (ctx->check_issued(ctx, xi, xi))

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 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:328:5: 
  326.       if (!st || (i < 0) || (i >= st->num))
  327.           return NULL;
  328. >     return st->data[i];
  329.   }
  330.   

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_vfy.c:1526:9: Taking false branch
1524.       xi = sk_X509_value(ctx->chain, n);
1525.   
1526.       if (ctx->check_issued(ctx, xi, xi))
                ^
1527.           xs = xi;
1528.       else {

crypto/x509/x509_vfy.c:1529:13: Taking false branch
1527.           xs = xi;
1528.       else {
1529.           if (ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN) {
                    ^
1530.               xs = xi;
1531.               goto check_cert;

crypto/x509/x509_vfy.c:1533:13: Taking false branch
1531.               goto check_cert;
1532.           }
1533.           if (n <= 0) {
                    ^
1534.               ctx->error = X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;
1535.               ctx->current_cert = xi;

crypto/x509/x509_vfy.c:1539:13: 
1537.               goto end;
1538.           } else {
1539. >             n--;
1540.               ctx->error_depth = n;
1541.               xs = sk_X509_value(ctx->chain, n);

crypto/x509/x509_vfy.c:1540:13: 
1538.           } else {
1539.               n--;
1540. >             ctx->error_depth = n;
1541.               xs = sk_X509_value(ctx->chain, n);
1542.           }

crypto/x509/x509_vfy.c:1541:18: Condition is true
1539.               n--;
1540.               ctx->error_depth = n;
1541.               xs = sk_X509_value(ctx->chain, n);
                         ^
1542.           }
1543.       }

crypto/x509/x509_vfy.c:1541:13: 
1539.               n--;
1540.               ctx->error_depth = n;
1541. >             xs = sk_X509_value(ctx->chain, n);
1542.           }
1543.       }

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_vfy.c:1549:12: Loop condition is true. Entering loop body
1547.        * is allowed to reset errors (at its own peril).
1548.        */
1549.       while (n >= 0) {
                   ^
1550.           ctx->error_depth = n;
1551.   

crypto/x509/x509_vfy.c:1550:9: 
1548.        */
1549.       while (n >= 0) {
1550. >         ctx->error_depth = n;
1551.   
1552.           /*

crypto/x509/x509_vfy.c:1557:14: Taking false branch
1555.            * time.
1556.            */
1557.           if (!xs->valid
                     ^
1558.               && (xs != xi
1559.                   || (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE))) {
