Skip to content

Commit

Permalink
ASAN: Avoid runtime errors on field[1]
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Jan 4, 2025
1 parent 4224bc9 commit b627ef7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/os/dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ extern "C" char *dtoa(double d, int mode, int ndigits,
Bigint {
struct Bigint *next;
int k, maxwds, sign, wds;
ULong x[1];
ULong x[];
};

typedef struct Bigint Bigint;
Expand Down Expand Up @@ -550,9 +550,9 @@ Balloc
else {
x = 1 << k;
#ifdef Omit_Private_Memory
rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
rv = (Bigint *)MALLOC(offsetof(struct Bigint, x[x]));
#else
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
len = (offsetof(struct Bigint, x[x]) + sizeof(double) - 1)
/sizeof(double);
if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {
rv = (Bigint*)pmem_next;
Expand Down

0 comments on commit b627ef7

Please sign in to comment.