mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-13 07:10:20 +02:00
fix segfaults when closing the current input port
* libguile/ports.c (scm_char_ready_p, scm_peek_char, scm_unread_char) (scm_unread_string): Always validate the port, even in the case that we get it the default current-input-port. Otherwise the following causes a segfault: (begin (close-port (current-input-port)) (peek-char))
This commit is contained in:
parent
1924145df5
commit
b2456dd434
1 changed files with 6 additions and 8 deletions
|
@ -261,7 +261,8 @@ SCM_DEFINE (scm_char_ready_p, "char-ready?", 0, 1, 0,
|
||||||
|
|
||||||
if (SCM_UNBNDP (port))
|
if (SCM_UNBNDP (port))
|
||||||
port = scm_current_input_port ();
|
port = scm_current_input_port ();
|
||||||
else
|
/* It's possible to close the current input port, so validate even in
|
||||||
|
this case. */
|
||||||
SCM_VALIDATE_OPINPORT (1, port);
|
SCM_VALIDATE_OPINPORT (1, port);
|
||||||
|
|
||||||
pt = SCM_PTAB_ENTRY (port);
|
pt = SCM_PTAB_ENTRY (port);
|
||||||
|
@ -1656,7 +1657,6 @@ SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0,
|
||||||
|
|
||||||
if (SCM_UNBNDP (port))
|
if (SCM_UNBNDP (port))
|
||||||
port = scm_current_input_port ();
|
port = scm_current_input_port ();
|
||||||
else
|
|
||||||
SCM_VALIDATE_OPINPORT (1, port);
|
SCM_VALIDATE_OPINPORT (1, port);
|
||||||
|
|
||||||
column = SCM_COL (port);
|
column = SCM_COL (port);
|
||||||
|
@ -1695,7 +1695,6 @@ SCM_DEFINE (scm_unread_char, "unread-char", 1, 1, 0,
|
||||||
SCM_VALIDATE_CHAR (1, cobj);
|
SCM_VALIDATE_CHAR (1, cobj);
|
||||||
if (SCM_UNBNDP (port))
|
if (SCM_UNBNDP (port))
|
||||||
port = scm_current_input_port ();
|
port = scm_current_input_port ();
|
||||||
else
|
|
||||||
SCM_VALIDATE_OPINPORT (2, port);
|
SCM_VALIDATE_OPINPORT (2, port);
|
||||||
|
|
||||||
c = SCM_CHAR (cobj);
|
c = SCM_CHAR (cobj);
|
||||||
|
@ -1717,7 +1716,6 @@ SCM_DEFINE (scm_unread_string, "unread-string", 2, 0, 0,
|
||||||
SCM_VALIDATE_STRING (1, str);
|
SCM_VALIDATE_STRING (1, str);
|
||||||
if (SCM_UNBNDP (port))
|
if (SCM_UNBNDP (port))
|
||||||
port = scm_current_input_port ();
|
port = scm_current_input_port ();
|
||||||
else
|
|
||||||
SCM_VALIDATE_OPINPORT (2, port);
|
SCM_VALIDATE_OPINPORT (2, port);
|
||||||
|
|
||||||
n = scm_i_string_length (str);
|
n = scm_i_string_length (str);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue