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


apps/opt.c:470:1: start of procedure opt_verify()
468.   enum range { OPT_V_ENUM };
469.   
470. > int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
471.   {
472.       int i;

apps/opt.c:473:5: 
471.   {
472.       int i;
473. >     ossl_intmax_t t = 0;
474.       ASN1_OBJECT *otmp;
475.       X509_PURPOSE *xptmp;

apps/opt.c:478:5: Condition is true
476.       const X509_VERIFY_PARAM *vtmp;
477.   
478.       assert(vpm != NULL);
           ^
479.       assert(opt > OPT_V__FIRST);
480.       assert(opt < OPT_V__LAST);

apps/opt.c:479:5: Condition is true
477.   
478.       assert(vpm != NULL);
479.       assert(opt > OPT_V__FIRST);
           ^
480.       assert(opt < OPT_V__LAST);
481.   

apps/opt.c:480:5: Condition is true
478.       assert(vpm != NULL);
479.       assert(opt > OPT_V__FIRST);
480.       assert(opt < OPT_V__LAST);
           ^
481.   
482.       switch ((enum range)opt) {

apps/opt.c:482:5: 
480.       assert(opt < OPT_V__LAST);
481.   
482. >     switch ((enum range)opt) {
483.       case OPT_V__FIRST:
484.       case OPT_V__LAST:

apps/opt.c:483:5: Switch condition is false. Skipping switch case
481.   
482.       switch ((enum range)opt) {
483.       case OPT_V__FIRST:
           ^
484.       case OPT_V__LAST:
485.           return 0;

apps/opt.c:484:5: Switch condition is false. Skipping switch case
482.       switch ((enum range)opt) {
483.       case OPT_V__FIRST:
484.       case OPT_V__LAST:
           ^
485.           return 0;
486.       case OPT_V_POLICY:

apps/opt.c:486:5: Switch condition is false. Skipping switch case
484.       case OPT_V__LAST:
485.           return 0;
486.       case OPT_V_POLICY:
           ^
487.           otmp = OBJ_txt2obj(opt_arg(), 0);
488.           if (otmp == NULL) {

apps/opt.c:494:5: Switch condition is true. Entering switch case
492.           X509_VERIFY_PARAM_add0_policy(vpm, otmp);
493.           break;
494.       case OPT_V_PURPOSE:
           ^
495.           /* purpose name -> purpose index */
496.           i = X509_PURPOSE_get_by_sname(opt_arg());

apps/opt.c:496:9: 
494.       case OPT_V_PURPOSE:
495.           /* purpose name -> purpose index */
496. >         i = X509_PURPOSE_get_by_sname(opt_arg());
497.           if (i < 0) {
498.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

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

apps/opt.c:777:5: 
  775.   char *opt_arg(void)
  776.   {
  777. >     return arg;
  778.   }
  779.   

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

apps/opt.c:496:9: Skipping X509_PURPOSE_get_by_sname(): empty list of specs
494.       case OPT_V_PURPOSE:
495.           /* purpose name -> purpose index */
496.           i = X509_PURPOSE_get_by_sname(opt_arg());
               ^
497.           if (i < 0) {
498.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:497:13: Taking false branch
495.           /* purpose name -> purpose index */
496.           i = X509_PURPOSE_get_by_sname(opt_arg());
497.           if (i < 0) {
                   ^
498.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());
499.               return 0;

apps/opt.c:503:9: 
501.   
502.           /* purpose index -> purpose object */
503. >         xptmp = X509_PURPOSE_get0(i);
504.   
505.           /* purpose object -> purpose value */

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:499:1: start of procedure sk_X509_PURPOSE_value()
    497.   # define X509V3_ADD_SILENT               0x10
    498.   
    499. > DEFINE_STACK_OF(X509_PURPOSE)
    500.   
    501.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

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

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

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

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

include/openssl/x509v3.h:499:1: return from a call to sk_X509_PURPOSE_value
    497.   # define X509V3_ADD_SILENT               0x10
    498.   
    499. > DEFINE_STACK_OF(X509_PURPOSE)
    500.   
    501.   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:506:9: 
504.   
505.           /* purpose object -> purpose value */
506. >         i = X509_PURPOSE_get_id(xptmp);
507.   
508.           if (!X509_VERIFY_PARAM_set_purpose(vpm, i)) {

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.   
