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


apps/opt.c:434:1: start of procedure opt_verify()
432.   enum range { OPT_V_ENUM };
433.   
434. > int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
435.   {
436.       int i;

apps/opt.c:437:5: 
435.   {
436.       int i;
437. >     ossl_intmax_t t = 0;
438.       ASN1_OBJECT *otmp;
439.       X509_PURPOSE *xptmp;

apps/opt.c:442:5: 
440.       const X509_VERIFY_PARAM *vtmp;
441.   
442. >     assert(vpm != NULL);
443.       assert(opt > OPT_V__FIRST);
444.       assert(opt < OPT_V__LAST);

apps/opt.c:443:5: 
441.   
442.       assert(vpm != NULL);
443. >     assert(opt > OPT_V__FIRST);
444.       assert(opt < OPT_V__LAST);
445.   

apps/opt.c:444:5: 
442.       assert(vpm != NULL);
443.       assert(opt > OPT_V__FIRST);
444. >     assert(opt < OPT_V__LAST);
445.   
446.       switch ((enum range)opt) {

apps/opt.c:446:5: 
444.       assert(opt < OPT_V__LAST);
445.   
446. >     switch ((enum range)opt) {
447.       case OPT_V__FIRST:
448.       case OPT_V__LAST:

apps/opt.c:447:5: Switch condition is false. Skipping switch case
445.   
446.       switch ((enum range)opt) {
447.       case OPT_V__FIRST:
           ^
448.       case OPT_V__LAST:
449.           return 0;

apps/opt.c:448:5: Switch condition is false. Skipping switch case
446.       switch ((enum range)opt) {
447.       case OPT_V__FIRST:
448.       case OPT_V__LAST:
           ^
449.           return 0;
450.       case OPT_V_POLICY:

apps/opt.c:450:5: Switch condition is false. Skipping switch case
448.       case OPT_V__LAST:
449.           return 0;
450.       case OPT_V_POLICY:
           ^
451.           otmp = OBJ_txt2obj(opt_arg(), 0);
452.           if (otmp == NULL) {

apps/opt.c:458:5: Switch condition is true. Entering switch case
456.           X509_VERIFY_PARAM_add0_policy(vpm, otmp);
457.           break;
458.       case OPT_V_PURPOSE:
           ^
459.           /* purpose name -> purpose index */
460.           i = X509_PURPOSE_get_by_sname(opt_arg());

apps/opt.c:460:9: 
458.       case OPT_V_PURPOSE:
459.           /* purpose name -> purpose index */
460. >         i = X509_PURPOSE_get_by_sname(opt_arg());
461.           if (i < 0) {
462.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:749:1: start of procedure opt_arg()
  747.   
  748.   /* Return the most recent flag parameter. */
  749. > char *opt_arg(void)
  750.   {
  751.       return arg;

apps/opt.c:751:5: 
  749.   char *opt_arg(void)
  750.   {
  751. >     return arg;
  752.   }
  753.   

apps/opt.c:752:1: return from a call to opt_arg
  750.   {
  751.       return arg;
  752. > }
  753.   
  754.   /* Return the most recent flag. */

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

apps/opt.c:461:13: Taking false branch
459.           /* purpose name -> purpose index */
460.           i = X509_PURPOSE_get_by_sname(opt_arg());
461.           if (i < 0) {
                   ^
462.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());
463.               return 0;

apps/opt.c:467:9: 
465.   
466.           /* purpose index -> purpose object */
467. >         xptmp = X509_PURPOSE_get0(i);
468.   
469.           /* 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:470:9: 
468.   
469.           /* purpose object -> purpose value */
470. >         i = X509_PURPOSE_get_id(xptmp);
471.   
472.           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.   
