apps/opt.c:511: error: NULL_DEREFERENCE
  pointer `xptmp` last assigned on line 510 could be null and is dereferenced by call to `X509_PURPOSE_get_id()` at line 511, column 13.
Showing all 31 steps of the trace


apps/opt.c:480:1: start of procedure opt_verify()
478.   enum range { OPT_V_ENUM };
479.   
480. > int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
481.   {
482.       int i;

apps/opt.c:483:5: 
481.   {
482.       int i;
483. >     ossl_intmax_t t = 0;
484.       ASN1_OBJECT *otmp;
485.       X509_PURPOSE *xptmp;

apps/opt.c:488:5: Condition is true
486.       const X509_VERIFY_PARAM *vtmp;
487.   
488.       assert(vpm != NULL);
           ^
489.       assert(opt > OPT_V__FIRST);
490.       assert(opt < OPT_V__LAST);

apps/opt.c:489:5: Condition is true
487.   
488.       assert(vpm != NULL);
489.       assert(opt > OPT_V__FIRST);
           ^
490.       assert(opt < OPT_V__LAST);
491.   

apps/opt.c:490:5: Condition is true
488.       assert(vpm != NULL);
489.       assert(opt > OPT_V__FIRST);
490.       assert(opt < OPT_V__LAST);
           ^
491.   
492.       switch ((enum range)opt) {

apps/opt.c:492:5: 
490.       assert(opt < OPT_V__LAST);
491.   
492. >     switch ((enum range)opt) {
493.       case OPT_V__FIRST:
494.       case OPT_V__LAST:

apps/opt.c:493:5: Switch condition is false. Skipping switch case
491.   
492.       switch ((enum range)opt) {
493.       case OPT_V__FIRST:
           ^
494.       case OPT_V__LAST:
495.           return 0;

apps/opt.c:494:5: Switch condition is false. Skipping switch case
492.       switch ((enum range)opt) {
493.       case OPT_V__FIRST:
494.       case OPT_V__LAST:
           ^
495.           return 0;
496.       case OPT_V_POLICY:

apps/opt.c:496:5: Switch condition is false. Skipping switch case
494.       case OPT_V__LAST:
495.           return 0;
496.       case OPT_V_POLICY:
           ^
497.           otmp = OBJ_txt2obj(opt_arg(), 0);
498.           if (otmp == NULL) {

apps/opt.c:504:5: Switch condition is true. Entering switch case
502.           X509_VERIFY_PARAM_add0_policy(vpm, otmp);
503.           break;
504.       case OPT_V_PURPOSE:
           ^
505.           i = X509_PURPOSE_get_by_sname(opt_arg());
506.           if (i < 0) {

apps/opt.c:505:9: 
503.           break;
504.       case OPT_V_PURPOSE:
505. >         i = X509_PURPOSE_get_by_sname(opt_arg());
506.           if (i < 0) {
507.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:772:1: start of procedure opt_arg()
  770.   
  771.   /* Return the most recent flag parameter. */
  772. > char *opt_arg(void)
  773.   {
  774.       return arg;

apps/opt.c:774:5: 
  772.   char *opt_arg(void)
  773.   {
  774. >     return arg;
  775.   }
  776.   

apps/opt.c:775:1: return from a call to opt_arg
  773.   {
  774.       return arg;
  775. > }
  776.   
  777.   /* Return the most recent flag. */

apps/opt.c:505:9: Skipping X509_PURPOSE_get_by_sname(): empty list of specs
503.           break;
504.       case OPT_V_PURPOSE:
505.           i = X509_PURPOSE_get_by_sname(opt_arg());
               ^
506.           if (i < 0) {
507.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:506:13: Taking false branch
504.       case OPT_V_PURPOSE:
505.           i = X509_PURPOSE_get_by_sname(opt_arg());
506.           if (i < 0) {
                   ^
507.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());
508.               return 0;

apps/opt.c:510:9: 
508.               return 0;
509.           }
510. >         xptmp = X509_PURPOSE_get0(i);
511.           i = X509_PURPOSE_get_id(xptmp);
512.           X509_VERIFY_PARAM_set_purpose(vpm, i);

crypto/x509v3/v3_purp.c:162:1: start of procedure X509_PURPOSE_get0()
  160.   }
  161.   
  162. > X509_PURPOSE *X509_PURPOSE_get0(int idx)
  163.   {
  164.       if (idx < 0)

crypto/x509v3/v3_purp.c:164:9: Taking false branch
  162.   X509_PURPOSE *X509_PURPOSE_get0(int idx)
  163.   {
  164.       if (idx < 0)
                 ^
  165.           return NULL;
  166.       if (idx < (int)X509_PURPOSE_COUNT)

crypto/x509v3/v3_purp.c:166:9: Taking false branch
  164.       if (idx < 0)
  165.           return NULL;
  166.       if (idx < (int)X509_PURPOSE_COUNT)
                 ^
  167.           return xstandard + idx;
  168.       return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);

crypto/x509v3/v3_purp.c:168:5: 
  166.       if (idx < (int)X509_PURPOSE_COUNT)
  167.           return xstandard + idx;
  168. >     return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  169.   }
  170.   

include/openssl/x509v3.h:500:1: start of procedure sk_X509_PURPOSE_value()
    498.   # define X509V3_ADD_SILENT               0x10
    499.   
    500. > DEFINE_STACK_OF(X509_PURPOSE)
    501.   
    502.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

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/x509v3.h:500:1: return from a call to sk_X509_PURPOSE_value
    498.   # define X509V3_ADD_SILENT               0x10
    499.   
    500. > DEFINE_STACK_OF(X509_PURPOSE)
    501.   
    502.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

crypto/x509v3/v3_purp.c:169:1: return from a call to X509_PURPOSE_get0
  167.           return xstandard + idx;
  168.       return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  169. > }
  170.   
  171.   int X509_PURPOSE_get_by_sname(char *sname)

apps/opt.c:511:9: 
509.           }
510.           xptmp = X509_PURPOSE_get0(i);
511. >         i = X509_PURPOSE_get_id(xptmp);
512.           X509_VERIFY_PARAM_set_purpose(vpm, i);
513.           break;

crypto/x509v3/v3_purp.c:281:1: start of procedure X509_PURPOSE_get_id()
  279.   }
  280.   
  281. > int X509_PURPOSE_get_id(X509_PURPOSE *xp)
  282.   {
  283.       return xp->purpose;

crypto/x509v3/v3_purp.c:283:5: 
  281.   int X509_PURPOSE_get_id(X509_PURPOSE *xp)
  282.   {
  283. >     return xp->purpose;
  284.   }
  285.   
