Fix memory allocation for small number of digits

svn path=/trunk/; revision=42616
This commit is contained in:
Gregor Schneider 2009-08-11 14:01:44 +00:00
parent 85fc2afbaa
commit dd9eabe375

View file

@ -7,6 +7,7 @@
*/
#include <precomp.h>
#define NUMBER_EFMT 18 /* sign, dot, null, 15 for alignment */
/*
* @implemented
@ -17,7 +18,7 @@ _ecvt (double value, int ndigits, int *decpt, int *sign)
static char ecvtbuf[DBL_MAX_10_EXP + 10];
char *cvtbuf, *s, *d;
s = cvtbuf = (char*)malloc(ndigits + 18); /* sign, dot, null, 15 for alignment */
s = cvtbuf = (char*)malloc(ndigits + NUMBER_EFMT);
d = ecvtbuf;
*sign = 0;
@ -90,7 +91,7 @@ _ecvt (double value, int ndigits, int *decpt, int *sign)
if (ndigits < 1)
{
/* Need enhanced precision*/
char* tbuf = (char*)malloc(ndigits + 18);
char* tbuf = (char*)malloc(NUMBER_EFMT);
if (tbuf == NULL)
{
free(cvtbuf);