summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-10-09 18:22:13 +0300
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-10-09 18:22:13 +0300
commitd5380843c63b84e550bf3cd33c70bbf626743c67 (patch)
tree8d0637e9640a353d2c5629f8f6f5019fa743ee28
parentNEWS: Bump version to 0.10.0 (diff)
downloadguile-ssh-d5380843c63b84e550bf3cd33c70bbf626743c67.tar.gz
libguile-ssh: Bugfix: Fix SMOB freeing callbacks
The SMOB freeing callbacks would always fail to free any resources due to mistaken use of 'SCM_SMOB_PREDICATE' procedure -- the procedure doesn't work in these GC callbacks according to the documentation (see '(guile) Smobs') and always returns 'false' as the result when used in such context. The solution is to remove the check 'SCM_SMOB_PREDICATE' and just get the SMOB's data. Reported by: David Kastrup <dak@gnu.org> Reported by: Ludovic Courtès <ludo@gnu.org> * libguile-ssh/key-type.c, libguile-ssh/message-type.c, libguile-ssh/server-type.c, libguile-ssh/session-type.c, libguile-ssh/sftp-session-type.c: Bugfix: Fix SMOB freeing callbacks. * NEWS: Update.
-rw-r--r--NEWS7
-rw-r--r--libguile-ssh/key-type.c9
-rw-r--r--libguile-ssh/message-type.c9
-rw-r--r--libguile-ssh/server-type.c9
-rw-r--r--libguile-ssh/session-type.c13
-rw-r--r--libguile-ssh/sftp-session-type.c9
6 files changed, 19 insertions, 37 deletions
diff --git a/NEWS b/NEWS
index 4f315d3..41ce39b 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,13 @@ Copyright (C) Artyom V. Poptsov <poptsov.artyom@gmail.com>
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
+* Unreleased
+** Bugfixes
+*** Fix SMOB freeing callbacks
+ Callbacks for many Guile-SSH objects would always fail to free allocated
+ resources due to wrong check added in 0.10.0. The problem should be fixed
+ now.
+
* Changes in version 0.10.0 (2016-08-20)
** Add support of Guile 2.0.12
Guile-SSH now builds (and works quite well, as far as I can see) with Guile
diff --git a/libguile-ssh/key-type.c b/libguile-ssh/key-type.c
index 8bb8f28..0e16382 100644
--- a/libguile-ssh/key-type.c
+++ b/libguile-ssh/key-type.c
@@ -57,14 +57,7 @@ mark_key_smob (SCM key_smob)
size_t
free_key_smob (SCM arg1)
{
- struct key_data *data;
- if (! SCM_SMOB_PREDICATE (key_tag, arg1))
- {
- _ssh_log (SSH_LOG_FUNCTIONS, "free_key_smob", "%s", "already freed");
- return 0;
- }
-
- data = _scm_to_key_data (arg1);
+ struct key_data *data = (struct key_data *) SCM_SMOB_DATA (arg1);
if (scm_is_false (data->parent))
{
diff --git a/libguile-ssh/message-type.c b/libguile-ssh/message-type.c
index 46b91f1..f303f87 100644
--- a/libguile-ssh/message-type.c
+++ b/libguile-ssh/message-type.c
@@ -41,13 +41,8 @@ mark_message (SCM message)
size_t
free_message (SCM message)
{
- if (! SCM_SMOB_PREDICATE (message_tag, message))
- {
- _ssh_log (SSH_LOG_FUNCTIONS, "free_message", "%s", "already freed");
- return 0;
- }
- struct message_data *msg_data = _scm_to_message_data (message);
- ssh_message_free (msg_data->message);
+ struct message_data *md = (struct message_data *) SCM_SMOB_DATA (message);
+ ssh_message_free (md->message);
return 0;
}
diff --git a/libguile-ssh/server-type.c b/libguile-ssh/server-type.c
index 5bb5e2e..d6fee52 100644
--- a/libguile-ssh/server-type.c
+++ b/libguile-ssh/server-type.c
@@ -41,13 +41,8 @@ mark_server (SCM server)
size_t
free_server (SCM server)
{
- if (! SCM_SMOB_PREDICATE (server_tag, server))
- {
- _ssh_log (SSH_LOG_FUNCTIONS, "free_server", "%s", "already freed");
- return 0;
- }
- struct server_data *server_data = _scm_to_server_data (server);
- ssh_bind_free (server_data->bind);
+ struct server_data *sd = (struct server_data *) SCM_SMOB_DATA (server);
+ ssh_bind_free (sd->bind);
return 0;
}
diff --git a/libguile-ssh/session-type.c b/libguile-ssh/session-type.c
index a766329..358ba2e 100644
--- a/libguile-ssh/session-type.c
+++ b/libguile-ssh/session-type.c
@@ -1,6 +1,6 @@
/* session-type.c -- SSH session smob.
*
- * Copyright (C) 2013 Artyom V. Poptsov <poptsov.artyom@gmail.com>
+ * Copyright (C) 2013, 2014, 2015, 2016 Artyom V. Poptsov <poptsov.artyom@gmail.com>
*
* This file is part of Guile-SSH.
*
@@ -41,15 +41,10 @@ mark_session (SCM session_smob)
size_t
free_session (SCM session_smob)
{
- if (! SCM_SMOB_PREDICATE (session_tag, session_smob))
- {
- _ssh_log (SSH_LOG_FUNCTIONS, "free_session", "%s", "already freed");
- return 0;
- }
- struct session_data *data = _scm_to_session_data (session_smob);
+ struct session_data *sd = (struct session_data *) SCM_SMOB_DATA (session_smob);
- ssh_disconnect (data->ssh_session);
- ssh_free (data->ssh_session);
+ ssh_disconnect (sd->ssh_session);
+ ssh_free (sd->ssh_session);
SCM_SET_SMOB_DATA (session_smob, NULL);
diff --git a/libguile-ssh/sftp-session-type.c b/libguile-ssh/sftp-session-type.c
index ae59c57..81b2d66 100644
--- a/libguile-ssh/sftp-session-type.c
+++ b/libguile-ssh/sftp-session-type.c
@@ -42,12 +42,9 @@ mark_sftp_session (SCM sftp_session)
static size_t
free_sftp_session (SCM sftp_session)
{
- if (! SCM_SMOB_PREDICATE (sftp_session_tag, sftp_session))
- {
- _ssh_log (SSH_LOG_FUNCTIONS, "free_sftp_session", "%s", "already freed");
- return 0;
- }
- struct sftp_session_data *sftp_sd = _scm_to_sftp_session_data (sftp_session);
+ struct sftp_session_data *sftp_sd
+ = (struct sftp_session_data *) SCM_SMOB_DATA (sftp_session);
+
sftp_free (sftp_sd->sftp_session);
return 0;
}