diff --git a/src/knownhost.c b/src/knownhost.c index 409ef29..7fe1e97 100644 --- a/src/knownhost.c +++ b/src/knownhost.c @@ -354,12 +354,13 @@ libssh2_knownhost_del(LIBSSH2_KNOWNHOSTS *hosts, /* unlink from the list of all hosts */ _libssh2_list_remove(&node->node); + /* clear the struct now since the memory in which it is allocated is + about to be freed! */ + memset(entry, 0, sizeof(struct libssh2_knownhost)); + /* free all resources */ free_host(hosts->session, node); - /* clear the struct now since this host entry has been removed! */ - memset(entry, 0, sizeof(struct libssh2_knownhost)); - return 0; }