crypto/pkcs12/p12_npas.c:140: error: MEMORY_LEAK
  memory dynamically allocated by call to `sk_new()` at line 114, column 18 is not reachable after line 140, column 16.
Showing all 57 steps of the trace


crypto/pkcs12/p12_npas.c:105:1: start of procedure newpass_p12()
103.   /* Parse the outer PKCS#12 structure */
104.   
105. > static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
106.   {
107.   	STACK *asafes, *newsafes, *bags;

crypto/pkcs12/p12_npas.c:110:2: 
108.   	int i, bagnid, pbe_nid, pbe_iter, pbe_saltlen;
109.   	PKCS7 *p7, *p7new;
110. > 	ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL;
111.   	unsigned char mac[EVP_MAX_MD_SIZE];
112.   	unsigned int maclen;

crypto/pkcs12/p12_npas.c:113:8: 
111.   	unsigned char mac[EVP_MAX_MD_SIZE];
112.   	unsigned int maclen;
113. > 	if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
114.   	if(!(newsafes = sk_new(NULL))) return 0;
115.   	for (i = 0; i < sk_num (asafes); i++) {

crypto/asn1/asn_pack.c:67:1: start of procedure ASN1_seq_unpack()
  65.   /* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
  66.   
  67. > STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
  68.   	     void (*free_func)())
  69.   {

crypto/asn1/asn_pack.c:72:5: 
  70.       STACK *sk;
  71.       unsigned char *pbuf;
  72. >     pbuf =  buf;
  73.       if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func,
  74.   					V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL)))

crypto/asn1/asn_pack.c:73:11: Taking false branch
  71.       unsigned char *pbuf;
  72.       pbuf =  buf;
  73.       if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func,
                  ^
  74.   					V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL)))
  75.   		 ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR);

crypto/asn1/asn_pack.c:76:5: 
  74.   					V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL)))
  75.   		 ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR);
  76. >     return sk;
  77.   }
  78.   

crypto/asn1/asn_pack.c:77:1: return from a call to ASN1_seq_unpack
  75.   		 ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR);
  76.       return sk;
  77. > }
  78.   
  79.   /* Turn a STACK structures into an ASN1 encoded SEQUENCE OF structure in a

crypto/pkcs12/p12_npas.c:113:8: Taking false branch
111.   	unsigned char mac[EVP_MAX_MD_SIZE];
112.   	unsigned int maclen;
113.   	if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
              ^
114.   	if(!(newsafes = sk_new(NULL))) return 0;
115.   	for (i = 0; i < sk_num (asafes); i++) {

crypto/pkcs12/p12_npas.c:114:7: 
112.   	unsigned int maclen;
113.   	if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
114. > 	if(!(newsafes = sk_new(NULL))) return 0;
115.   	for (i = 0; i < sk_num (asafes); i++) {
116.   		p7 = (PKCS7 *) sk_value(asafes, i);

crypto/stack/stack.c:112:1: start of procedure sk_new()
  110.   	}
  111.   
  112. > STACK *sk_new(int (*c)())
  113.   	{
  114.   	STACK *ret;

crypto/stack/stack.c:117:6: Taking false branch
  115.   	int i;
  116.   
  117.   	if ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL)
              ^
  118.   		goto err0;
  119.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)

crypto/stack/stack.c:119:6: Taking false branch
  117.   	if ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL)
  118.   		goto err0;
  119.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
              ^
  120.   		goto err1;
  121.   	for (i=0; i<MIN_NODES; i++)

crypto/stack/stack.c:121:7: 
  119.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
  120.   		goto err1;
  121. > 	for (i=0; i<MIN_NODES; i++)
  122.   		ret->data[i]=NULL;
  123.   	ret->comp=c;

crypto/stack/stack.c:121:12: Loop condition is true. Entering loop body
  119.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
  120.   		goto err1;
  121.   	for (i=0; i<MIN_NODES; i++)
                    ^
  122.   		ret->data[i]=NULL;
  123.   	ret->comp=c;

crypto/stack/stack.c:122:3: 
  120.   		goto err1;
  121.   	for (i=0; i<MIN_NODES; i++)
  122. > 		ret->data[i]=NULL;
  123.   	ret->comp=c;
  124.   	ret->num_alloc=MIN_NODES;

crypto/stack/stack.c:121:25: 
  119.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
  120.   		goto err1;
  121. > 	for (i=0; i<MIN_NODES; i++)
  122.   		ret->data[i]=NULL;
  123.   	ret->comp=c;

crypto/stack/stack.c:121:12: Loop condition is false. Leaving loop
  119.   	if ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)
  120.   		goto err1;
  121.   	for (i=0; i<MIN_NODES; i++)
                    ^
  122.   		ret->data[i]=NULL;
  123.   	ret->comp=c;

crypto/stack/stack.c:123:2: 
  121.   	for (i=0; i<MIN_NODES; i++)
  122.   		ret->data[i]=NULL;
  123. > 	ret->comp=c;
  124.   	ret->num_alloc=MIN_NODES;
  125.   	ret->num=0;

crypto/stack/stack.c:124:2: 
  122.   		ret->data[i]=NULL;
  123.   	ret->comp=c;
  124. > 	ret->num_alloc=MIN_NODES;
  125.   	ret->num=0;
  126.   	ret->sorted=0;

crypto/stack/stack.c:125:2: 
  123.   	ret->comp=c;
  124.   	ret->num_alloc=MIN_NODES;
  125. > 	ret->num=0;
  126.   	ret->sorted=0;
  127.   	return(ret);

crypto/stack/stack.c:126:2: 
  124.   	ret->num_alloc=MIN_NODES;
  125.   	ret->num=0;
  126. > 	ret->sorted=0;
  127.   	return(ret);
  128.   err1:

crypto/stack/stack.c:127:2: 
  125.   	ret->num=0;
  126.   	ret->sorted=0;
  127. > 	return(ret);
  128.   err1:
  129.   	Free((char *)ret);

crypto/stack/stack.c:132:2: return from a call to sk_new
  130.   err0:
  131.   	return(NULL);
  132.   	}
          ^
  133.   
  134.   int sk_insert(STACK *st, char *data, int loc)

crypto/pkcs12/p12_npas.c:114:7: Taking false branch
112.   	unsigned int maclen;
113.   	if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
114.   	if(!(newsafes = sk_new(NULL))) return 0;
             ^
115.   	for (i = 0; i < sk_num (asafes); i++) {
116.   		p7 = (PKCS7 *) sk_value(asafes, i);

crypto/pkcs12/p12_npas.c:115:7: 
113.   	if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
114.   	if(!(newsafes = sk_new(NULL))) return 0;
115. > 	for (i = 0; i < sk_num (asafes); i++) {
116.   		p7 = (PKCS7 *) sk_value(asafes, i);
117.   		bagnid = OBJ_obj2nid(p7->type);

crypto/pkcs12/p12_npas.c:115:14: 
113.   	if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
114.   	if(!(newsafes = sk_new(NULL))) return 0;
115. > 	for (i = 0; i < sk_num (asafes); i++) {
116.   		p7 = (PKCS7 *) sk_value(asafes, i);
117.   		bagnid = OBJ_obj2nid(p7->type);

crypto/stack/stack.c:283:1: start of procedure sk_num()
  281.   	}
  282.   
  283. > int sk_num(STACK *st)
  284.   {
  285.   	if(st == NULL) return -1;

crypto/stack/stack.c:285:5: Taking false branch
  283.   int sk_num(STACK *st)
  284.   {
  285.   	if(st == NULL) return -1;
             ^
  286.   	return st->num;
  287.   }

crypto/stack/stack.c:286:2: 
  284.   {
  285.   	if(st == NULL) return -1;
  286. > 	return st->num;
  287.   }
  288.   

crypto/stack/stack.c:287:1: return from a call to sk_num
  285.   	if(st == NULL) return -1;
  286.   	return st->num;
  287. > }
  288.   
  289.   char *sk_value(STACK *st, int i)

crypto/pkcs12/p12_npas.c:115:14: Loop condition is true. Entering loop body
113.   	if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
114.   	if(!(newsafes = sk_new(NULL))) return 0;
115.   	for (i = 0; i < sk_num (asafes); i++) {
                    ^
116.   		p7 = (PKCS7 *) sk_value(asafes, i);
117.   		bagnid = OBJ_obj2nid(p7->type);

crypto/pkcs12/p12_npas.c:116:3: 
114.   	if(!(newsafes = sk_new(NULL))) return 0;
115.   	for (i = 0; i < sk_num (asafes); i++) {
116. > 		p7 = (PKCS7 *) sk_value(asafes, i);
117.   		bagnid = OBJ_obj2nid(p7->type);
118.   		if (bagnid == NID_pkcs7_data) {

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 false 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:292:2: 
  290.   {
  291.   	if(st == NULL) return NULL;
  292. > 	return st->data[i];
  293.   }
  294.   

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/pkcs12/p12_npas.c:117:3: 
115.   	for (i = 0; i < sk_num (asafes); i++) {
116.   		p7 = (PKCS7 *) sk_value(asafes, i);
117. > 		bagnid = OBJ_obj2nid(p7->type);
118.   		if (bagnid == NID_pkcs7_data) {
119.   			bags = M_PKCS12_unpack_p7data(p7);

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/pkcs12/p12_npas.c:118:7: Taking true branch
116.   		p7 = (PKCS7 *) sk_value(asafes, i);
117.   		bagnid = OBJ_obj2nid(p7->type);
118.   		if (bagnid == NID_pkcs7_data) {
             ^
119.   			bags = M_PKCS12_unpack_p7data(p7);
120.   		} else if (bagnid == NID_pkcs7_encrypted) {

crypto/pkcs12/p12_npas.c:119:4: 
117.   		bagnid = OBJ_obj2nid(p7->type);
118.   		if (bagnid == NID_pkcs7_data) {
119. > 			bags = M_PKCS12_unpack_p7data(p7);
120.   		} else if (bagnid == NID_pkcs7_encrypted) {
121.   			bags = M_PKCS12_unpack_p7encdata(p7, oldpass, -1);

crypto/asn1/asn_pack.c:67:1: start of procedure ASN1_seq_unpack()
  65.   /* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
  66.   
  67. > STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
  68.   	     void (*free_func)())
  69.   {

crypto/asn1/asn_pack.c:72:5: 
  70.       STACK *sk;
  71.       unsigned char *pbuf;
  72. >     pbuf =  buf;
  73.       if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func,
  74.   					V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL)))

crypto/asn1/asn_pack.c:73:11: Taking false branch
  71.       unsigned char *pbuf;
  72.       pbuf =  buf;
  73.       if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func,
                  ^
  74.   					V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL)))
  75.   		 ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR);

crypto/asn1/asn_pack.c:76:5: 
  74.   					V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL)))
  75.   		 ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR);
  76. >     return sk;
  77.   }
  78.   

crypto/asn1/asn_pack.c:77:1: return from a call to ASN1_seq_unpack
  75.   		 ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR);
  76.       return sk;
  77. > }
  78.   
  79.   /* Turn a STACK structures into an ASN1 encoded SEQUENCE OF structure in a

crypto/pkcs12/p12_npas.c:125:8: Taking false branch
123.   				&pbe_nid, &pbe_iter, &pbe_saltlen);
124.   		} else continue;
125.   		if (!bags) {
              ^
126.   			sk_pop_free(asafes, PKCS7_free);
127.   			return 0;

crypto/pkcs12/p12_npas.c:129:12: Taking false branch
127.   			return 0;
128.   		}
129.   	    	if (!newpass_bags(bags, oldpass, newpass)) {
                  ^
130.   			sk_pop_free(bags, PKCS12_SAFEBAG_free);
131.   			sk_pop_free(asafes, PKCS7_free);

crypto/pkcs12/p12_npas.c:135:7: Taking true branch
133.   		}
134.   		/* Repack bag in same form with new password */
135.   		if (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags);
             ^
136.   		else p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
137.   						 pbe_saltlen, pbe_iter, bags);

crypto/pkcs12/p12_npas.c:135:33: Skipping PKCS12_pack_p7data(): empty list of specs
133.   		}
134.   		/* Repack bag in same form with new password */
135.   		if (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags);
                                       ^
136.   		else p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
137.   						 pbe_saltlen, pbe_iter, bags);

crypto/pkcs12/p12_npas.c:138:3: Skipping sk_pop_free(): empty list of specs
136.   		else p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
137.   						 pbe_saltlen, pbe_iter, bags);
138.   		sk_pop_free(bags, PKCS12_SAFEBAG_free);
         ^
139.   		if(!p7new) {
140.   			sk_pop_free(asafes, PKCS7_free);

crypto/pkcs12/p12_npas.c:139:7: Taking true branch
137.   						 pbe_saltlen, pbe_iter, bags);
138.   		sk_pop_free(bags, PKCS12_SAFEBAG_free);
139.   		if(!p7new) {
             ^
140.   			sk_pop_free(asafes, PKCS7_free);
141.   			return 0;

crypto/pkcs12/p12_npas.c:140:4: 
138.   		sk_pop_free(bags, PKCS12_SAFEBAG_free);
139.   		if(!p7new) {
140. > 			sk_pop_free(asafes, PKCS7_free);
141.   			return 0;
142.   		}

static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
{
	STACK *asafes, *newsafes, *bags;
	int i, bagnid, pbe_nid, pbe_iter, pbe_saltlen;
	PKCS7 *p7, *p7new;
	ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL;
	unsigned char mac[EVP_MAX_MD_SIZE];
	unsigned int maclen;
	if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;
	if(!(newsafes = sk_new(NULL))) return 0;
	for (i = 0; i < sk_num (asafes); i++) {
		p7 = (PKCS7 *) sk_value(asafes, i);
		bagnid = OBJ_obj2nid(p7->type);
		if (bagnid == NID_pkcs7_data) {
			bags = M_PKCS12_unpack_p7data(p7);
		} else if (bagnid == NID_pkcs7_encrypted) {
			bags = M_PKCS12_unpack_p7encdata(p7, oldpass, -1);
			alg_get(p7->d.encrypted->enc_data->algorithm,
				&pbe_nid, &pbe_iter, &pbe_saltlen);
		} else continue;
		if (!bags) {
			sk_pop_free(asafes, PKCS7_free);
			return 0;
		}
	    	if (!newpass_bags(bags, oldpass, newpass)) {
			sk_pop_free(bags, PKCS12_SAFEBAG_free);
			sk_pop_free(asafes, PKCS7_free);
			return 0;
		}
		if (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags);
		else p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
						 pbe_saltlen, pbe_iter, bags);
		sk_pop_free(bags, PKCS12_SAFEBAG_free);
		if(!p7new) {
			sk_pop_free(asafes, PKCS7_free);
			return 0;
		}
		sk_push(newsafes, (char *)p7new);
	}
	sk_pop_free(asafes, PKCS7_free);
	p12_data_tmp = p12->authsafes->d.data;
	if(!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) goto saferr;
	if(!M_PKCS12_pack_authsafes(p12, newsafes)) goto saferr;
	if(!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr;
	if(!(macnew = ASN1_OCTET_STRING_new())) goto saferr;
	if(!ASN1_OCTET_STRING_set(macnew, mac, maclen)) goto saferr;
	ASN1_OCTET_STRING_free(p12->mac->dinfo->digest);
	p12->mac->dinfo->digest = macnew;
	ASN1_OCTET_STRING_free(p12_data_tmp);
	return 1;
	saferr:
	ASN1_OCTET_STRING_free(p12->authsafes->d.data);
	ASN1_OCTET_STRING_free(macnew);
	p12->authsafes->d.data = p12_data_tmp;
	return 0;
}
['static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)\n{\n\tSTACK *asafes, *newsafes, *bags;\n\tint i, bagnid, pbe_nid, pbe_iter, pbe_saltlen;\n\tPKCS7 *p7, *p7new;\n\tASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL;\n\tunsigned char mac[EVP_MAX_MD_SIZE];\n\tunsigned int maclen;\n\tif (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;\n\tif(!(newsafes = sk_new(NULL))) return 0;\n\tfor (i = 0; i < sk_num (asafes); i++) {\n\t\tp7 = (PKCS7 *) sk_value(asafes, i);\n\t\tbagnid = OBJ_obj2nid(p7->type);\n\t\tif (bagnid == NID_pkcs7_data) {\n\t\t\tbags = M_PKCS12_unpack_p7data(p7);\n\t\t} else if (bagnid == NID_pkcs7_encrypted) {\n\t\t\tbags = M_PKCS12_unpack_p7encdata(p7, oldpass, -1);\n\t\t\talg_get(p7->d.encrypted->enc_data->algorithm,\n\t\t\t\t&pbe_nid, &pbe_iter, &pbe_saltlen);\n\t\t} else continue;\n\t\tif (!bags) {\n\t\t\tsk_pop_free(asafes, PKCS7_free);\n\t\t\treturn 0;\n\t\t}\n\t    \tif (!newpass_bags(bags, oldpass, newpass)) {\n\t\t\tsk_pop_free(bags, PKCS12_SAFEBAG_free);\n\t\t\tsk_pop_free(asafes, PKCS7_free);\n\t\t\treturn 0;\n\t\t}\n\t\tif (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags);\n\t\telse p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,\n\t\t\t\t\t\t pbe_saltlen, pbe_iter, bags);\n\t\tsk_pop_free(bags, PKCS12_SAFEBAG_free);\n\t\tif(!p7new) {\n\t\t\tsk_pop_free(asafes, PKCS7_free);\n\t\t\treturn 0;\n\t\t}\n\t\tsk_push(newsafes, (char *)p7new);\n\t}\n\tsk_pop_free(asafes, PKCS7_free);\n\tp12_data_tmp = p12->authsafes->d.data;\n\tif(!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) goto saferr;\n\tif(!M_PKCS12_pack_authsafes(p12, newsafes)) goto saferr;\n\tif(!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr;\n\tif(!(macnew = ASN1_OCTET_STRING_new())) goto saferr;\n\tif(!ASN1_OCTET_STRING_set(macnew, mac, maclen)) goto saferr;\n\tASN1_OCTET_STRING_free(p12->mac->dinfo->digest);\n\tp12->mac->dinfo->digest = macnew;\n\tASN1_OCTET_STRING_free(p12_data_tmp);\n\treturn 1;\n\tsaferr:\n\tASN1_OCTET_STRING_free(p12->authsafes->d.data);\n\tASN1_OCTET_STRING_free(macnew);\n\tp12->authsafes->d.data = p12_data_tmp;\n\treturn 0;\n}', 'STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),\n\t     void (*free_func)())\n{\n    STACK *sk;\n    unsigned char *pbuf;\n    pbuf =  buf;\n    if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func,\n\t\t\t\t\tV_ASN1_SEQUENCE, V_ASN1_UNIVERSAL)))\n\t\t ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR);\n    return sk;\n}', 'STACK *sk_new(int (*c)())\n\t{\n\tSTACK *ret;\n\tint i;\n\tif ((ret=(STACK *)Malloc(sizeof(STACK))) == NULL)\n\t\tgoto err0;\n\tif ((ret->data=(char **)Malloc(sizeof(char *)*MIN_NODES)) == NULL)\n\t\tgoto err1;\n\tfor (i=0; i<MIN_NODES; i++)\n\t\tret->data[i]=NULL;\n\tret->comp=c;\n\tret->num_alloc=MIN_NODES;\n\tret->num=0;\n\tret->sorted=0;\n\treturn(ret);\nerr1:\n\tFree((char *)ret);\nerr0:\n\treturn(NULL);\n\t}', 'int sk_num(STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}', 'char *sk_value(STACK *st, int i)\n{\n\tif(st == NULL) return NULL;\n\treturn st->data[i];\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}']