From f499754bc8291a044c5034b634ac02a01bde9b49 Mon Sep 17 00:00:00 2001 From: Daniel Llorens Date: Fri, 21 May 2021 14:19:49 +0200 Subject: [PATCH] Fix bug in nftw function Fixes bug #44182. Thanks to Matija Obid for the report and RhodiumToad in --- module/ice-9/ftw.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module/ice-9/ftw.scm b/module/ice-9/ftw.scm index dd6f49089..ac6aa6316 100644 --- a/module/ice-9/ftw.scm +++ b/module/ice-9/ftw.scm @@ -307,10 +307,10 @@ (else (values s (easy-flag s)))))))) (define (clean name) - (let ((last-char-index (1- (string-length name)))) - (if (char=? #\/ (string-ref name last-char-index)) - (substring name 0 last-char-index) - name))) + (let ((end (- (string-length name) 1))) + (if (and (positive? end) (char=? #\/ (string-ref name end))) + (substring name 0 end) + name))) (define (ftw filename proc . options) (let* ((visited? (visited?-proc (cond ((memq 'hash-size options) => cadr)