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


apps/opt.c:453:1: start of procedure opt_verify()
451.   enum range { OPT_V_ENUM };
452.   
453. > int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
454.   {
455.       int i;

apps/opt.c:456:5: 
454.   {
455.       int i;
456. >     ossl_intmax_t t = 0;
457.       ASN1_OBJECT *otmp;
458.       X509_PURPOSE *xptmp;

apps/opt.c:461:5: 
459.       const X509_VERIFY_PARAM *vtmp;
460.   
461. >     assert(vpm != NULL);
462.       assert(opt > OPT_V__FIRST);
463.       assert(opt < OPT_V__LAST);

apps/opt.c:462:5: 
460.   
461.       assert(vpm != NULL);
462. >     assert(opt > OPT_V__FIRST);
463.       assert(opt < OPT_V__LAST);
464.   

apps/opt.c:463:5: 
461.       assert(vpm != NULL);
462.       assert(opt > OPT_V__FIRST);
463. >     assert(opt < OPT_V__LAST);
464.   
465.       switch ((enum range)opt) {

apps/opt.c:465:5: 
463.       assert(opt < OPT_V__LAST);
464.   
465. >     switch ((enum range)opt) {
466.       case OPT_V__FIRST:
467.       case OPT_V__LAST:

apps/opt.c:466:5: Switch condition is false. Skipping switch case
464.   
465.       switch ((enum range)opt) {
466.       case OPT_V__FIRST:
           ^
467.       case OPT_V__LAST:
468.           return 0;

apps/opt.c:467:5: Switch condition is false. Skipping switch case
465.       switch ((enum range)opt) {
466.       case OPT_V__FIRST:
467.       case OPT_V__LAST:
           ^
468.           return 0;
469.       case OPT_V_POLICY:

apps/opt.c:469:5: Switch condition is false. Skipping switch case
467.       case OPT_V__LAST:
468.           return 0;
469.       case OPT_V_POLICY:
           ^
470.           otmp = OBJ_txt2obj(opt_arg(), 0);
471.           if (otmp == NULL) {

apps/opt.c:477:5: Switch condition is true. Entering switch case
475.           X509_VERIFY_PARAM_add0_policy(vpm, otmp);
476.           break;
477.       case OPT_V_PURPOSE:
           ^
478.           /* purpose name -> purpose index */
479.           i = X509_PURPOSE_get_by_sname(opt_arg());

apps/opt.c:479:9: 
477.       case OPT_V_PURPOSE:
478.           /* purpose name -> purpose index */
479. >         i = X509_PURPOSE_get_by_sname(opt_arg());
480.           if (i < 0) {
481.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:758:1: start of procedure opt_arg()
  756.   
  757.   /* Return the most recent flag parameter. */
  758. > char *opt_arg(void)
  759.   {
  760.       return arg;

apps/opt.c:760:5: 
  758.   char *opt_arg(void)
  759.   {
  760. >     return arg;
  761.   }
  762.   

apps/opt.c:761:1: return from a call to opt_arg
  759.   {
  760.       return arg;
  761. > }
  762.   
  763.   /* Return the most recent flag. */

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

apps/opt.c:480:13: Taking false branch
478.           /* purpose name -> purpose index */
479.           i = X509_PURPOSE_get_by_sname(opt_arg());
480.           if (i < 0) {
                   ^
481.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());
482.               return 0;

apps/opt.c:486:9: 
484.   
485.           /* purpose index -> purpose object */
486. >         xptmp = X509_PURPOSE_get0(i);
487.   
488.           /* purpose object -> purpose value */

crypto/x509v3/v3_purp.c:112:1: start of procedure X509_PURPOSE_get0()
  110.   }
  111.   
  112. > X509_PURPOSE *X509_PURPOSE_get0(int idx)
  113.   {
  114.       if (idx < 0)

crypto/x509v3/v3_purp.c:114:9: Taking false branch
  112.   X509_PURPOSE *X509_PURPOSE_get0(int idx)
  113.   {
  114.       if (idx < 0)
                 ^
  115.           return NULL;
  116.       if (idx < (int)X509_PURPOSE_COUNT)

crypto/x509v3/v3_purp.c:116:9: Taking false branch
  114.       if (idx < 0)
  115.           return NULL;
  116.       if (idx < (int)X509_PURPOSE_COUNT)
                 ^
  117.           return xstandard + idx;
  118.       return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);

crypto/x509v3/v3_purp.c:118:5: 
  116.       if (idx < (int)X509_PURPOSE_COUNT)
  117.           return xstandard + idx;
  118. >     return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  119.   }
  120.   

include/openssl/x509v3.h:448:1: start of procedure sk_X509_PURPOSE_value()
    446.   # define X509V3_ADD_SILENT               0x10
    447.   
    448. > DEFINE_STACK_OF(X509_PURPOSE)
    449.   
    450.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

crypto/stack/stack.c:385:1: start of procedure OPENSSL_sk_value()
      383.   }
      384.   
      385. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
      386.   {
      387.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:387:9: Taking true branch
      385.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
      386.   {
      387.       if (st == NULL || i < 0 || i >= st->num)
                     ^
      388.           return NULL;
      389.       return (void *)st->data[i];

crypto/stack/stack.c:388:9: 
      386.   {
      387.       if (st == NULL || i < 0 || i >= st->num)
      388. >         return NULL;
      389.       return (void *)st->data[i];
      390.   }

crypto/stack/stack.c:390:1: return from a call to OPENSSL_sk_value
      388.           return NULL;
      389.       return (void *)st->data[i];
      390. > }
      391.   
      392.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

include/openssl/x509v3.h:448:1: return from a call to sk_X509_PURPOSE_value
    446.   # define X509V3_ADD_SILENT               0x10
    447.   
    448. > DEFINE_STACK_OF(X509_PURPOSE)
    449.   
    450.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

crypto/x509v3/v3_purp.c:119:1: return from a call to X509_PURPOSE_get0
  117.           return xstandard + idx;
  118.       return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  119. > }
  120.   
  121.   int X509_PURPOSE_get_by_sname(const char *sname)

apps/opt.c:489:9: 
487.   
488.           /* purpose object -> purpose value */
489. >         i = X509_PURPOSE_get_id(xptmp);
490.   
491.           if (!X509_VERIFY_PARAM_set_purpose(vpm, i)) {

crypto/x509v3/v3_purp.c:236:1: start of procedure X509_PURPOSE_get_id()
  234.   }
  235.   
  236. > int X509_PURPOSE_get_id(const X509_PURPOSE *xp)
  237.   {
  238.       return xp->purpose;

crypto/x509v3/v3_purp.c:238:5: 
  236.   int X509_PURPOSE_get_id(const X509_PURPOSE *xp)
  237.   {
  238. >     return xp->purpose;
  239.   }
  240.   
