crypto/evp/evp_pbe.c:97: error: NULL_DEREFERENCE
  pointer `pbetmp` last assigned on line 96 could be null and is dereferenced at line 97, column 8.
Showing all 18 steps of the trace


crypto/evp/evp_pbe.c:77:1: start of procedure EVP_PBE_CipherInit()
75.   } EVP_PBE_CTL;
76.   
77. > int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
78.   	     ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de)
79.   {

crypto/evp/evp_pbe.c:83:2: 
81.   	EVP_PBE_CTL *pbetmp, pbelu;
82.   	int i;
83. > 	pbelu.pbe_nid = OBJ_obj2nid(pbe_obj);
84.   	if (pbelu.pbe_nid != NID_undef) i = sk_find(pbe_algs, (char *)&pbelu);
85.   	else i = -1;

crypto/objects/obj_dat.c:354:1: start of procedure OBJ_obj2nid()
  352.   	}
  353.   
  354. > int OBJ_obj2nid(ASN1_OBJECT *a)
  355.   	{
  356.   	ASN1_OBJECT **op;

crypto/objects/obj_dat.c:359:6: Taking false branch
  357.   	ADDED_OBJ ad,*adp;
  358.   
  359.   	if (a == NULL)
              ^
  360.   		return(NID_undef);
  361.   	if (a->nid != 0)

crypto/objects/obj_dat.c:361:6: Taking true branch
  359.   	if (a == NULL)
  360.   		return(NID_undef);
  361.   	if (a->nid != 0)
              ^
  362.   		return(a->nid);
  363.   

crypto/objects/obj_dat.c:362:3: 
  360.   		return(NID_undef);
  361.   	if (a->nid != 0)
  362. > 		return(a->nid);
  363.   
  364.   	if (added != NULL)

crypto/objects/obj_dat.c:376:2: return from a call to OBJ_obj2nid
  374.   		return(NID_undef);
  375.   	return((*op)->nid);
  376.   	}
          ^
  377.   
  378.   /* Convert an object name into an ASN1_OBJECT

crypto/evp/evp_pbe.c:84:6: Taking true branch
82.   	int i;
83.   	pbelu.pbe_nid = OBJ_obj2nid(pbe_obj);
84.   	if (pbelu.pbe_nid != NID_undef) i = sk_find(pbe_algs, (char *)&pbelu);
           ^
85.   	else i = -1;
86.   

crypto/evp/evp_pbe.c:84:34: Skipping sk_find(): empty list of specs
82.   	int i;
83.   	pbelu.pbe_nid = OBJ_obj2nid(pbe_obj);
84.   	if (pbelu.pbe_nid != NID_undef) i = sk_find(pbe_algs, (char *)&pbelu);
                                       ^
85.   	else i = -1;
86.   

crypto/evp/evp_pbe.c:87:6: Taking false branch
85.   	else i = -1;
86.   
87.   	if (i == -1) {
           ^
88.   		char obj_tmp[80];
89.   		EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM);

crypto/evp/evp_pbe.c:95:6: Taking true branch
93.   		return 0;
94.   	}
95.   	if (passlen == -1) passlen = strlen(pass);
           ^
96.   	pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i);
97.   	i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher,

crypto/evp/evp_pbe.c:95:21: 
93.   		return 0;
94.   	}
95. > 	if (passlen == -1) passlen = strlen(pass);
96.   	pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i);
97.   	i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher,

crypto/evp/evp_pbe.c:96:2: 
94.   	}
95.   	if (passlen == -1) passlen = strlen(pass);
96. > 	pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i);
97.   	i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher,
98.   						 pbetmp->md, en_de);

crypto/stack/stack.c:289:1: start of procedure sk_value()
  287.   }
  288.   
  289. > char *sk_value(STACK *st, int i)
  290.   {
  291.   	if(st == NULL) return NULL;

crypto/stack/stack.c:291:5: Taking true branch
  289.   char *sk_value(STACK *st, int i)
  290.   {
  291.   	if(st == NULL) return NULL;
             ^
  292.   	return st->data[i];
  293.   }

crypto/stack/stack.c:291:17: 
  289.   char *sk_value(STACK *st, int i)
  290.   {
  291. > 	if(st == NULL) return NULL;
  292.   	return st->data[i];
  293.   }

crypto/stack/stack.c:293:1: return from a call to sk_value
  291.   	if(st == NULL) return NULL;
  292.   	return st->data[i];
  293. > }
  294.   
  295.   char *sk_set(STACK *st, int i, char *value)

crypto/evp/evp_pbe.c:97:2: 
95.   	if (passlen == -1) passlen = strlen(pass);
96.   	pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i);
97. > 	i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher,
98.   						 pbetmp->md, en_de);
99.   	if (!i) {

int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
	     ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de)
{
	EVP_PBE_CTL *pbetmp, pbelu;
	int i;
	pbelu.pbe_nid = OBJ_obj2nid(pbe_obj);
	if (pbelu.pbe_nid != NID_undef) i = sk_find(pbe_algs, (char *)&pbelu);
	else i = -1;
	if (i == -1) {
		char obj_tmp[80];
		EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM);
		if (!pbe_obj) strcpy (obj_tmp, "NULL");
		else i2t_ASN1_OBJECT(obj_tmp, 80, pbe_obj);
		ERR_add_error_data(2, "TYPE=", obj_tmp);
		return 0;
	}
	if (passlen == -1) passlen = strlen(pass);
	pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i);
	i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher,
						 pbetmp->md, en_de);
	if (!i) {
		EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_KEYGEN_FAILURE);
		return 0;
	}
	return 1;
}
['int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,\n\t     ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de)\n{\n\tEVP_PBE_CTL *pbetmp, pbelu;\n\tint i;\n\tpbelu.pbe_nid = OBJ_obj2nid(pbe_obj);\n\tif (pbelu.pbe_nid != NID_undef) i = sk_find(pbe_algs, (char *)&pbelu);\n\telse i = -1;\n\tif (i == -1) {\n\t\tchar obj_tmp[80];\n\t\tEVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM);\n\t\tif (!pbe_obj) strcpy (obj_tmp, "NULL");\n\t\telse i2t_ASN1_OBJECT(obj_tmp, 80, pbe_obj);\n\t\tERR_add_error_data(2, "TYPE=", obj_tmp);\n\t\treturn 0;\n\t}\n\tif (passlen == -1) passlen = strlen(pass);\n\tpbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i);\n\ti = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher,\n\t\t\t\t\t\t pbetmp->md, en_de);\n\tif (!i) {\n\t\tEVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_KEYGEN_FAILURE);\n\t\treturn 0;\n\t}\n\treturn 1;\n}', 'int OBJ_obj2nid(ASN1_OBJECT *a)\n\t{\n\tASN1_OBJECT **op;\n\tADDED_OBJ ad,*adp;\n\tif (a == NULL)\n\t\treturn(NID_undef);\n\tif (a->nid != 0)\n\t\treturn(a->nid);\n\tif (added != NULL)\n\t\t{\n\t\tad.type=ADDED_DATA;\n\t\tad.obj=a;\n\t\tadp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad);\n\t\tif (adp != NULL) return (adp->obj->nid);\n\t\t}\n\top=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ,\n\t\tsizeof(ASN1_OBJECT *),(int (*)())obj_cmp);\n\tif (op == NULL)\n\t\treturn(NID_undef);\n\treturn((*op)->nid);\n\t}', 'char *sk_value(STACK *st, int i)\n{\n\tif(st == NULL) return NULL;\n\treturn st->data[i];\n}']