From 7cea27ec208d669a9b004cae4ee8a102f857174e Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 3 May 2015 00:17:34 +0900 Subject: [PATCH] Open both input and output ports to the same fd before using either, to prevent one closing the fd. --- lib/chibi/snow/fort.scm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/chibi/snow/fort.scm b/lib/chibi/snow/fort.scm index e95df6df..7ec4592c 100644 --- a/lib/chibi/snow/fort.scm +++ b/lib/chibi/snow/fort.scm @@ -144,9 +144,10 @@ (call-with-locked-file path (lambda (fd) - (let* ((str (port->string (open-input-file-descriptor fd))) - (res (proc str)) - (out (open-output-file-descriptor fd))) + (let* ((in (open-input-file-descriptor fd)) + (out (open-output-file-descriptor fd)) + (str (port->string in)) + (res (proc str))) (set-file-position! out seek/set 0) (display res out) (file-truncate out (string-size res))