Skip to content

Commit 44693ee

Browse files
committed
Fix a possible memory leak in dtoa
Fix rubyGH-15061
1 parent 6af9b8d commit 44693ee

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

missing/dtoa.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,13 @@ Balloc(int k)
547547
}
548548

549549
static void
550-
Bfree(Bigint *v)
550+
Bclear(Bigint **vp)
551551
{
552-
FREE(v);
552+
Bigint *v = *vp;
553+
*vp = NULL;
554+
if (v) FREE(v);
553555
}
556+
#define Bfree(v) Bclear(&(v))
554557

555558
#define Bcopy(x,y) memcpy((char *)&(x)->sign, (char *)&(y)->sign, \
556559
(y)->wds*sizeof(Long) + 2*sizeof(int))

0 commit comments

Comments
 (0)