diff options
-rw-r--r-- | libguile/print.c | 2 | ||||
-rw-r--r-- | test-suite/tests/format.test | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/libguile/print.c b/libguile/print.c index 60683b517..7e27f7670 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -1468,7 +1468,7 @@ SCM_DEFINE (scm_simple_format, "simple-format", 2, 0, 1, if (scm_is_eq (destination, SCM_BOOL_T)) { destination = port = scm_current_output_port (); - SCM_VALIDATE_OPORT_VALUE (0, destination); + SCM_VALIDATE_OPORT_VALUE (1, destination); } else if (scm_is_false (destination)) { diff --git a/test-suite/tests/format.test b/test-suite/tests/format.test index 334984703..cc31942cc 100644 --- a/test-suite/tests/format.test +++ b/test-suite/tests/format.test @@ -24,6 +24,22 @@ #:use-module (ice-9 format)) +(with-test-prefix "simple-format" + (pass-if-exception "current-output-port is closed" + exception:wrong-type-arg + ;; This used to segfault in Guile <= 2.0.10. + (let ((old (current-output-port)) + (new (%make-void-port "w"))) + (dynamic-wind + (lambda () + (set-current-output-port new) + (close-port new)) + (lambda () + (simple-format #t "hello, closed port!") + #t) + (lambda () + (set-current-output-port old)))))) + ;;; FORMAT Basic Output (with-test-prefix "format basic output" |