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


apps/opt.c:458:1: start of procedure opt_verify()
456.   enum range { OPT_V_ENUM };
457.   
458. > int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
459.   {
460.       int i;

apps/opt.c:461:5: 
459.   {
460.       int i;
461. >     ossl_intmax_t t = 0;
462.       ASN1_OBJECT *otmp;
463.       X509_PURPOSE *xptmp;

apps/opt.c:466:5: Condition is true
464.       const X509_VERIFY_PARAM *vtmp;
465.   
466.       OPENSSL_assert(vpm != NULL);
           ^
467.       OPENSSL_assert(opt > OPT_V__FIRST);
468.       OPENSSL_assert(opt < OPT_V__LAST);

apps/opt.c:467:5: Condition is true
465.   
466.       OPENSSL_assert(vpm != NULL);
467.       OPENSSL_assert(opt > OPT_V__FIRST);
           ^
468.       OPENSSL_assert(opt < OPT_V__LAST);
469.   

apps/opt.c:468:5: Condition is true
466.       OPENSSL_assert(vpm != NULL);
467.       OPENSSL_assert(opt > OPT_V__FIRST);
468.       OPENSSL_assert(opt < OPT_V__LAST);
           ^
469.   
470.       switch ((enum range)opt) {

apps/opt.c:470:5: 
468.       OPENSSL_assert(opt < OPT_V__LAST);
469.   
470. >     switch ((enum range)opt) {
471.       case OPT_V__FIRST:
472.       case OPT_V__LAST:

apps/opt.c:471:5: Switch condition is false. Skipping switch case
469.   
470.       switch ((enum range)opt) {
471.       case OPT_V__FIRST:
           ^
472.       case OPT_V__LAST:
473.           return 0;

apps/opt.c:472:5: Switch condition is false. Skipping switch case
470.       switch ((enum range)opt) {
471.       case OPT_V__FIRST:
472.       case OPT_V__LAST:
           ^
473.           return 0;
474.       case OPT_V_POLICY:

apps/opt.c:474:5: Switch condition is false. Skipping switch case
472.       case OPT_V__LAST:
473.           return 0;
474.       case OPT_V_POLICY:
           ^
475.           otmp = OBJ_txt2obj(opt_arg(), 0);
476.           if (otmp == NULL) {

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

apps/opt.c:484:9: 
482.       case OPT_V_PURPOSE:
483.           /* purpose name -> purpose index */
484. >         i = X509_PURPOSE_get_by_sname(opt_arg());
485.           if (i < 0) {
486.               opt_printf_stderr("%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:763:1: start of procedure opt_arg()
  761.   
  762.   /* Return the most recent flag parameter. */
  763. > char *opt_arg(void)
  764.   {
  765.       return arg;

apps/opt.c:765:5: 
  763.   char *opt_arg(void)
  764.   {
  765. >     return arg;
  766.   }
  767.   

apps/opt.c:766:1: return from a call to opt_arg
  764.   {
  765.       return arg;
  766. > }
  767.   
  768.   /* Return the most recent flag. */

apps/opt.c:484:9: Skipping X509_PURPOSE_get_by_sname(): empty list of specs
482.       case OPT_V_PURPOSE:
483.           /* purpose name -> purpose index */
484.           i = X509_PURPOSE_get_by_sname(opt_arg());
               ^
485.           if (i < 0) {
486.               opt_printf_stderr("%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:485:13: Taking false branch
483.           /* purpose name -> purpose index */
484.           i = X509_PURPOSE_get_by_sname(opt_arg());
485.           if (i < 0) {
                   ^
486.               opt_printf_stderr("%s: Invalid purpose %s\n", prog, opt_arg());
487.               return 0;

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