mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
Fixed potentially uninitialized memory bug in compatlib.
This commit is contained in:
parent
0637d52d1f
commit
90e53f0c16
@ -1705,6 +1705,10 @@ Thu Oct 30 11:12:37 CET 2003
|
|||||||
Fri Oct 31 15:09:22 CET 2003
|
Fri Oct 31 15:09:22 CET 2003
|
||||||
|
|
||||||
- If EOF is found inside a string/comment/etc. stop parsing.
|
- If EOF is found inside a string/comment/etc. stop parsing.
|
||||||
|
|
||||||
|
Mon Nov 3 15:43:19 CET 2003
|
||||||
|
|
||||||
|
- Fixed a potentially uncleared allocation in compatlib.
|
||||||
- Set ecpg version to 3.0.0
|
- Set ecpg version to 3.0.0
|
||||||
- Set ecpg library to 4.0.0
|
- Set ecpg library to 4.0.0
|
||||||
- Set pgtypes library to 1.0.0
|
- Set pgtypes library to 1.0.0
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <ecpgtype.h>
|
#include <ecpgtype.h>
|
||||||
#include <compatlib.h>
|
#include <compatlib.h>
|
||||||
@ -11,7 +12,7 @@
|
|||||||
#include <pgtypes_numeric.h>
|
#include <pgtypes_numeric.h>
|
||||||
#include <sqltypes.h>
|
#include <sqltypes.h>
|
||||||
|
|
||||||
char *ECPGalloc(long, int);
|
char *ECPGalloc(long, int);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
deccall2(decimal * arg1, decimal * arg2, int (*ptr) (numeric *, numeric *))
|
deccall2(decimal * arg1, decimal * arg2, int (*ptr) (numeric *, numeric *))
|
||||||
@ -659,41 +660,50 @@ static struct
|
|||||||
} value;
|
} value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialize the struct, wich holds the different forms
|
* initialize the struct, which holds the different forms
|
||||||
* of the long value
|
* of the long value
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
initValue(long lng_val)
|
initValue (long lng_val)
|
||||||
{
|
{
|
||||||
int i,
|
int i, j;
|
||||||
div,
|
long l, dig;
|
||||||
dig;
|
|
||||||
char tmp[2] = " ";
|
|
||||||
|
|
||||||
/* set some obvious things */
|
/* set some obvious things */
|
||||||
value.val = lng_val >= 0 ? lng_val : lng_val * (-1);
|
value.val = lng_val >= 0 ? lng_val : lng_val * (-1);
|
||||||
value.sign = lng_val >= 0 ? '+' : '-';
|
value.sign = lng_val >= 0 ? '+' : '-';
|
||||||
value.maxdigits = log10(2) * (8 * sizeof(long) - 1);
|
value.maxdigits = log10 (2) * (8 * sizeof (long) - 1);
|
||||||
|
|
||||||
/* determine the number of digits */
|
/* determine the number of digits */
|
||||||
for (i = 0; i <= value.maxdigits; i++)
|
i = 0;
|
||||||
{
|
l = 1;
|
||||||
if ((int) (value.val / pow(10, i)) != 0)
|
do
|
||||||
value.digits = i + 1;
|
{
|
||||||
}
|
i++;
|
||||||
value.remaining = value.digits;
|
l *= 10;
|
||||||
|
}
|
||||||
|
while ((l - 1) < value.val && l <= LONG_MAX / 10);
|
||||||
|
|
||||||
/* convert the long to string */
|
if (l <= LONG_MAX/10)
|
||||||
value.val_string = (char *) malloc(value.digits + 1);
|
{
|
||||||
for (i = value.digits; i > 0; i--)
|
value.digits = i;
|
||||||
{
|
l /= 10;
|
||||||
div = pow(10, i);
|
}
|
||||||
dig = (value.val % div) / (div / 10);
|
else
|
||||||
tmp[0] = (char) (dig + 48);
|
value.digits = i + 1;
|
||||||
strcat(value.val_string, tmp);
|
|
||||||
}
|
value.remaining = value.digits;
|
||||||
/* safety-net */
|
|
||||||
value.val_string[value.digits] = '\0';
|
/* convert the long to string */
|
||||||
|
value.val_string = (char *) malloc (value.digits + 1);
|
||||||
|
dig = value.val;
|
||||||
|
for (i = value.digits, j = 0; i > 0; i--, j++)
|
||||||
|
{
|
||||||
|
value.val_string[j] = dig/l + '0';
|
||||||
|
dig = dig % l;
|
||||||
|
l /= 10;
|
||||||
|
}
|
||||||
|
value.val_string[value.digits] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the position oft the right-most dot in some string */
|
/* return the position oft the right-most dot in some string */
|
||||||
|
Loading…
Reference in New Issue
Block a user