crypto/pkcs12/p12_sbag.c:153: error: NULL_DEREFERENCE
  pointer `pbe_ciph` last assigned on line 148 could be null and is dereferenced by call to `PKCS8_encrypt()` at line 153, column 10.
Showing all 39 steps of the trace


crypto/pkcs12/p12_sbag.c:137:1: start of procedure PKCS12_SAFEBAG_create_pkcs8_encrypt()
135.   }
136.   
137. > PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid,
138.                                                       const char *pass,
139.                                                       int passlen,

crypto/pkcs12/p12_sbag.c:148:5: 
146.       X509_SIG *p8;
147.   
148. >     pbe_ciph = EVP_get_cipherbynid(pbe_nid);
149.   
150.       if (pbe_ciph)

crypto/objects/obj_dat.c:247:1: start of procedure OBJ_nid2sn()
  245.   }
  246.   
  247. > const char *OBJ_nid2sn(int n)
  248.   {
  249.       ADDED_OBJ ad, *adp;

crypto/objects/obj_dat.c:252:10: Taking true branch
  250.       ASN1_OBJECT ob;
  251.   
  252.       if ((n >= 0) && (n < NUM_NID)) {
                  ^
  253.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  254.               OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:252:22: Taking false branch
  250.       ASN1_OBJECT ob;
  251.   
  252.       if ((n >= 0) && (n < NUM_NID)) {
                              ^
  253.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  254.               OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:258:16: Taking false branch
  256.           }
  257.           return nid_objs[n].sn;
  258.       } else if (added == NULL)
                        ^
  259.           return NULL;
  260.       else {

crypto/objects/obj_dat.c:261:9: 
  259.           return NULL;
  260.       else {
  261. >         ad.type = ADDED_NID;
  262.           ad.obj = &ob;
  263.           ob.nid = n;

crypto/objects/obj_dat.c:262:9: 
  260.       else {
  261.           ad.type = ADDED_NID;
  262. >         ad.obj = &ob;
  263.           ob.nid = n;
  264.           adp = lh_ADDED_OBJ_retrieve(added, &ad);

crypto/objects/obj_dat.c:263:9: 
  261.           ad.type = ADDED_NID;
  262.           ad.obj = &ob;
  263. >         ob.nid = n;
  264.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
  265.           if (adp != NULL)

crypto/objects/obj_dat.c:264:9: 
  262.           ad.obj = &ob;
  263.           ob.nid = n;
  264. >         adp = lh_ADDED_OBJ_retrieve(added, &ad);
  265.           if (adp != NULL)
  266.               return adp->obj->sn;

crypto/objects/obj_lcl.h:14:1: start of procedure lh_ADDED_OBJ_retrieve()
    12.   DEFINE_LHASH_OF(OBJ_NAME);
    13.   typedef struct added_obj_st ADDED_OBJ;
    14. > DEFINE_LHASH_OF(ADDED_OBJ);

crypto/lhash/lhash.c:134:1: start of procedure OPENSSL_LH_retrieve()
      132.   }
      133.   
      134. > void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data)
      135.   {
      136.       unsigned long hash;

crypto/lhash/lhash.c:141:5: 
      139.       int scratch;
      140.   
      141. >     lh->error = 0;
      142.       rn = getrn(lh, data, &hash);
      143.   

crypto/lhash/lhash.c:142:5: Skipping getrn(): empty list of specs
      140.   
      141.       lh->error = 0;
      142.       rn = getrn(lh, data, &hash);
                 ^
      143.   
      144.       if (*rn == NULL) {

crypto/lhash/lhash.c:144:9: Taking false branch
      142.       rn = getrn(lh, data, &hash);
      143.   
      144.       if (*rn == NULL) {
                     ^
      145.           CRYPTO_atomic_add(&lh->num_retrieve_miss, 1, &scratch, lh->retrieve_stats_lock);
      146.           return NULL;

crypto/lhash/lhash.c:148:9: 
      146.           return NULL;
      147.       } else {
      148. >         ret = (*rn)->data;
      149.           CRYPTO_atomic_add(&lh->num_retrieve, 1, &scratch, lh->retrieve_stats_lock);
      150.       }

crypto/lhash/lhash.c:149:9: 
      147.       } else {
      148.           ret = (*rn)->data;
      149. >         CRYPTO_atomic_add(&lh->num_retrieve, 1, &scratch, lh->retrieve_stats_lock);
      150.       }
      151.       return ret;

crypto/threads_pthread.c:152:1: start of procedure CRYPTO_atomic_add()
        150.   }
        151.   
        152. > int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
        153.   {
        154.   # if defined(__GNUC__) && defined(__ATOMIC_ACQ_REL)

crypto/threads_pthread.c:155:9: Taking false branch
        153.   {
        154.   # if defined(__GNUC__) && defined(__ATOMIC_ACQ_REL)
        155.       if (__atomic_is_lock_free(sizeof(*val), val)) {
                       ^
        156.           *ret = __atomic_add_fetch(val, amount, __ATOMIC_ACQ_REL);
        157.           return 1;

crypto/threads_pthread.c:160:10: 
        158.       }
        159.   # endif
        160. >     if (!CRYPTO_THREAD_write_lock(lock))
        161.           return 0;
        162.   

crypto/threads_pthread.c:64:1: start of procedure CRYPTO_THREAD_write_lock()
          62.   }
          63.   
          64. > int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
          65.   {
          66.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:67:9: Taking true branch
          65.   {
          66.   # ifdef USE_RWLOCK
          67.       if (pthread_rwlock_wrlock(lock) != 0)
                        ^
          68.           return 0;
          69.   # else

crypto/threads_pthread.c:68:9: 
          66.   # ifdef USE_RWLOCK
          67.       if (pthread_rwlock_wrlock(lock) != 0)
          68. >         return 0;
          69.   # else
          70.       if (pthread_mutex_lock(lock) != 0)

crypto/threads_pthread.c:75:1: return from a call to CRYPTO_THREAD_write_lock
          73.   
          74.       return 1;
          75. > }
          76.   
          77.   int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)

crypto/threads_pthread.c:160:10: Taking true branch
        158.       }
        159.   # endif
        160.       if (!CRYPTO_THREAD_write_lock(lock))
                        ^
        161.           return 0;
        162.   

crypto/threads_pthread.c:161:9: 
        159.   # endif
        160.       if (!CRYPTO_THREAD_write_lock(lock))
        161. >         return 0;
        162.   
        163.       *val += amount;

crypto/threads_pthread.c:170:1: return from a call to CRYPTO_atomic_add
        168.   
        169.       return 1;
        170. > }
        171.   
        172.   # ifdef OPENSSL_SYS_UNIX

crypto/lhash/lhash.c:151:5: 
      149.           CRYPTO_atomic_add(&lh->num_retrieve, 1, &scratch, lh->retrieve_stats_lock);
      150.       }
      151. >     return ret;
      152.   }
      153.   

crypto/lhash/lhash.c:152:1: return from a call to OPENSSL_LH_retrieve
      150.       }
      151.       return ret;
      152. > }
      153.   
      154.   static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,

crypto/objects/obj_lcl.h:14:1: return from a call to lh_ADDED_OBJ_retrieve
    12.   DEFINE_LHASH_OF(OBJ_NAME);
    13.   typedef struct added_obj_st ADDED_OBJ;
    14. > DEFINE_LHASH_OF(ADDED_OBJ);

crypto/objects/obj_dat.c:265:13: Taking true branch
  263.           ob.nid = n;
  264.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
  265.           if (adp != NULL)
                     ^
  266.               return adp->obj->sn;
  267.           else {

crypto/objects/obj_dat.c:266:13: 
  264.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
  265.           if (adp != NULL)
  266. >             return adp->obj->sn;
  267.           else {
  268.               OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:272:1: return from a call to OBJ_nid2sn
  270.           }
  271.       }
  272. > }
  273.   
  274.   const char *OBJ_nid2ln(int n)

crypto/evp/names.c:58:1: start of procedure EVP_get_cipherbyname()
  56.   }
  57.   
  58. > const EVP_CIPHER *EVP_get_cipherbyname(const char *name)
  59.   {
  60.       const EVP_CIPHER *cp;

crypto/evp/names.c:62:10: Taking true branch
  60.       const EVP_CIPHER *cp;
  61.   
  62.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL))
                 ^
  63.           return NULL;
  64.   

crypto/evp/names.c:63:9: 
  61.   
  62.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL))
  63. >         return NULL;
  64.   
  65.       cp = (const EVP_CIPHER *)OBJ_NAME_get(name, OBJ_NAME_TYPE_CIPHER_METH);

crypto/evp/names.c:67:1: return from a call to EVP_get_cipherbyname
  65.       cp = (const EVP_CIPHER *)OBJ_NAME_get(name, OBJ_NAME_TYPE_CIPHER_METH);
  66.       return (cp);
  67. > }
  68.   
  69.   const EVP_MD *EVP_get_digestbyname(const char *name)

crypto/pkcs12/p12_sbag.c:150:9: Taking false branch
148.       pbe_ciph = EVP_get_cipherbynid(pbe_nid);
149.   
150.       if (pbe_ciph)
               ^
151.           pbe_nid = -1;
152.   

crypto/pkcs12/p12_sbag.c:153:5: 
151.           pbe_nid = -1;
152.   
153. >     p8 = PKCS8_encrypt(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter,
154.                          p8inf);
155.   
