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


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

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

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

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

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

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

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

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

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

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

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

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

apps/opt.c:771:5: 
  769.   char *opt_arg(void)
  770.   {
  771. >     return arg;
  772.   }
  773.   

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

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

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

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

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

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

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

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

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:284:1: start of procedure OPENSSL_sk_value()
      282.   }
      283.   
      284. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
      285.   {
      286.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:286:9: Taking true branch
      284.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
      285.   {
      286.       if (st == NULL || i < 0 || i >= st->num)
                     ^
      287.           return NULL;
      288.       return (void *)st->data[i];

crypto/stack/stack.c:287:9: 
      285.   {
      286.       if (st == NULL || i < 0 || i >= st->num)
      287. >         return NULL;
      288.       return (void *)st->data[i];
      289.   }

crypto/stack/stack.c:289:1: return from a call to OPENSSL_sk_value
      287.           return NULL;
      288.       return (void *)st->data[i];
      289. > }
      290.   
      291.   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:120:1: return from a call to X509_PURPOSE_get0
  118.           return xstandard + idx;
  119.       return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  120. > }
  121.   
  122.   int X509_PURPOSE_get_by_sname(const char *sname)

apps/opt.c:490:9: 
488.   
489.           /* purpose object -> purpose value */
490. >         i = X509_PURPOSE_get_id(xptmp);
491.   
492.           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.   
