From 72edf5a953ae0b5ec3be8cfe6efd78eed5505f53 Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Thu, 6 May 2021 07:56:35 +0900 Subject: [PATCH] fix memory leak in close-file --- bootstrap.fs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bootstrap.fs b/bootstrap.fs index 9703971..622a198 100644 --- a/bootstrap.fs +++ b/bootstrap.fs @@ -2500,7 +2500,14 @@ need-defined (read) ; : close-file ( file -- e ) - file>fd @ (close) 0= if success else CLOSE-FILE-ERROR then + dup file>fd @ swap + ( fd file ) + \ release heap objects + dup file>rbuf @ (free) + dup file>wbuf @ (free) + (free) + \ close file object + (close) 0= if success else CLOSE-FILE-ERROR then ; ( === File Include === )