From: Taylor R Campbell Date: Tue, 19 Dec 2017 14:14:46 +0000 (+0000) Subject: Avoid stack overflow with long responses. X-Git-Tag: mit-scheme-pucked-9.2.12~14^2~4 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=243e64fe3226a8c1fe274872768468a88413f578;p=mit-scheme.git Avoid stack overflow with long responses. --- diff --git a/src/imail/imail-imap.scm b/src/imail/imail-imap.scm index 34f7c52bc..b4fed13a5 100644 --- a/src/imail/imail-imap.scm +++ b/src/imail/imail-imap.scm @@ -2680,12 +2680,15 @@ USA. (define (process-queued-responses connection command) (with-modification-events-deferred (lambda () - (let loop ((responses (dequeue-imap-responses connection))) + (let loop + ((responses (dequeue-imap-responses connection)) + (returned '())) (if (pair? responses) - (if (process-response connection command (car responses)) - (cons (car responses) (loop (cdr responses))) - (loop (cdr responses))) - '()))))) + (loop (cdr responses) + (if (process-response connection command (car responses)) + (cons (car responses) returned) + returned)) + (reverse! returned)))))) (define (process-response connection command response) (cond ((imap:response:status-response? response)