if (!BUF_MEM_grow(b,len+want))
if (!BUF_MEM_grow_clean(b,len+want))
static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)	{	BUF_MEM *b;	unsigned char *p;	int i;	int ret=-1;	ASN1_CTX c;	int want=HEADER_SIZE;	int eos=0;	int off=0;	int len=0;	b=BUF_MEM_new();	if (b == NULL)		{		ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);		return -1;		}	ERR_clear_error();	for (;;)		{		if (want >= (len-off))			{			want-=(len-off);			if (!BUF_MEM_grow(b,len+want))				{				ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);				goto err;				}			i=BIO_read(in,&(b->data[len]),want);			if ((i < 0) && ((len-off) == 0))				{				ASN1err(ASN1_F_ASN1_D2I_BIO,ASN1_R_NOT_ENOUGH_DATA);				goto err;				}			if (i > 0)				len+=i;			}		/* else data already loaded */		p=(unsigned char *)&(b->data[off]);		c.p=p;		c.inf=ASN1_get_object(&(c.p),&(c.slen),&(c.tag),&(c.xclass),			len-off);		if (c.inf & 0x80)			{			unsigned long e;			e=ERR_GET_REASON(ERR_peek_error());			if (e != ASN1_R_TOO_LONG)				goto err;			else				ERR_get_error(); /* clear error */			}		i=c.p-p;/* header length */		off+=i;	/* end of data */		if (c.inf & 1)			{			/* no data body so go round again */			eos++;			want=HEADER_SIZE;			}		else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC))			{			/* eos value, so go back and read another header */			eos--;			if (eos <= 0)				break;			else				want=HEADER_SIZE;			}		else 			{			/* suck in c.slen bytes of data */			want=(int)c.slen;			if (want > (len-off))				{				want-=(len-off);				if (!BUF_MEM_grow(b,len+want))					{					ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);					goto err;					}				i=BIO_read(in,&(b->data[len]),want);				if (i <= 0)					{					ASN1err(ASN1_F_ASN1_D2I_BIO,ASN1_R_NOT_ENOUGH_DATA);					goto err;					}				len+=i;				}			off+=(int)c.slen;			if (eos <= 0)				{				break;				}			else				want=HEADER_SIZE;			}		}	*pb = b;	return off;err:	if (b != NULL) BUF_MEM_free(b);	return(ret);	}