apps/opt.c:511: error: NULL_DEREFERENCE
  pointer `xptmp` last assigned on line 508 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:475:1: start of procedure opt_verify()
473.   enum range { OPT_V_ENUM };
474.   
475. > int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
476.   {
477.       int i;

apps/opt.c:478:5: 
476.   {
477.       int i;
478. >     ossl_intmax_t t = 0;
479.       ASN1_OBJECT *otmp;
480.       X509_PURPOSE *xptmp;

apps/opt.c:483:5: Condition is true
481.       const X509_VERIFY_PARAM *vtmp;
482.   
483.       assert(vpm != NULL);
           ^
484.       assert(opt > OPT_V__FIRST);
485.       assert(opt < OPT_V__LAST);

apps/opt.c:484:5: Condition is true
482.   
483.       assert(vpm != NULL);
484.       assert(opt > OPT_V__FIRST);
           ^
485.       assert(opt < OPT_V__LAST);
486.   

apps/opt.c:485:5: Condition is true
483.       assert(vpm != NULL);
484.       assert(opt > OPT_V__FIRST);
485.       assert(opt < OPT_V__LAST);
           ^
486.   
487.       switch ((enum range)opt) {

apps/opt.c:487:5: 
485.       assert(opt < OPT_V__LAST);
486.   
487. >     switch ((enum range)opt) {
488.       case OPT_V__FIRST:
489.       case OPT_V__LAST:

apps/opt.c:488:5: Switch condition is false. Skipping switch case
486.   
487.       switch ((enum range)opt) {
488.       case OPT_V__FIRST:
           ^
489.       case OPT_V__LAST:
490.           return 0;

apps/opt.c:489:5: Switch condition is false. Skipping switch case
487.       switch ((enum range)opt) {
488.       case OPT_V__FIRST:
489.       case OPT_V__LAST:
           ^
490.           return 0;
491.       case OPT_V_POLICY:

apps/opt.c:491:5: Switch condition is false. Skipping switch case
489.       case OPT_V__LAST:
490.           return 0;
491.       case OPT_V_POLICY:
           ^
492.           otmp = OBJ_txt2obj(opt_arg(), 0);
493.           if (otmp == NULL) {

apps/opt.c:499:5: Switch condition is true. Entering switch case
497.           X509_VERIFY_PARAM_add0_policy(vpm, otmp);
498.           break;
499.       case OPT_V_PURPOSE:
           ^
500.           /* purpose name -> purpose index */
501.           i = X509_PURPOSE_get_by_sname(opt_arg());

apps/opt.c:501:9: 
499.       case OPT_V_PURPOSE:
500.           /* purpose name -> purpose index */
501. >         i = X509_PURPOSE_get_by_sname(opt_arg());
502.           if (i < 0) {
503.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:780:1: start of procedure opt_arg()
  778.   
  779.   /* Return the most recent flag parameter. */
  780. > char *opt_arg(void)
  781.   {
  782.       return arg;

apps/opt.c:782:5: 
  780.   char *opt_arg(void)
  781.   {
  782. >     return arg;
  783.   }
  784.   

apps/opt.c:783:1: return from a call to opt_arg
  781.   {
  782.       return arg;
  783. > }
  784.   
  785.   /* Return the most recent flag. */

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

apps/opt.c:502:13: Taking false branch
500.           /* purpose name -> purpose index */
501.           i = X509_PURPOSE_get_by_sname(opt_arg());
502.           if (i < 0) {
                   ^
503.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());
504.               return 0;

apps/opt.c:508:9: 
506.   
507.           /* purpose index -> purpose object */
508. >         xptmp = X509_PURPOSE_get0(i);
509.   
510.           /* 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:511:9: 
509.   
510.           /* purpose object -> purpose value */
511. >         i = X509_PURPOSE_get_id(xptmp);
512.   
513.           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.   
