From dc63650fc9a1617933d7076961a52408ba0d54fd Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Wed, 12 Sep 2018 16:06:24 +0530
Subject: quoted-printable: Close port after use.

* email/quoted-printable.scm (quoted-printable-decode): Close
bytevector port after use.
In cond, use else instead of #t for the default clause.
---
 email/quoted-printable.scm | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

(limited to 'email')

diff --git a/email/quoted-printable.scm b/email/quoted-printable.scm
index f6e3605..317bf81 100644
--- a/email/quoted-printable.scm
+++ b/email/quoted-printable.scm
@@ -31,13 +31,14 @@
     (((? port? in))
      (let-values (((out get-bytevector)
 		   (open-bytevector-output-port)))
-       (quoted-printable-decode in out)
-       (get-bytevector)))
+       (call-with-port
+	out (lambda (out)
+	      (quoted-printable-decode in out)
+	      (get-bytevector)))))
     (((? port? in) (? port? out))
      (let ((c (read-char in)))
        (cond
-	((eof-object? c)
-	 out)
+	((eof-object? c) out)
 	((char=? c #\=)
 	 ;; TODO: Support "\r\n" line ending
 	 (let ((c1 (read-char in)))
@@ -45,9 +46,9 @@
 	     (let ((c2 (read-char in)))
 	       (put-u8 out (string->number (string c1 c2) 16)))))
 	 (quoted-printable-decode in out))
-	(#t
-	 (put-u8 out (char->integer c))
-	 (quoted-printable-decode in out)))))))
+	(else (put-u8 out (char->integer c))
+	      (quoted-printable-decode in out)))))))
+
 
 (define (q-encoding-decode str)
   (quoted-printable-decode
-- 
cgit v1.2.3