From 243e64fe3226a8c1fe274872768468a88413f578 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 19 Dec 2017 14:14:46 +0000 Subject: [PATCH] Avoid stack overflow with long responses. --- src/imail/imail-imap.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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) -- 2.25.1