diff --git a/source/libsmb/libsmbclient.c b/source/libsmb/libsmbclient.c index a85d9e45fc6..33aeb62af8f 100644 --- a/source/libsmb/libsmbclient.c +++ b/source/libsmb/libsmbclient.c @@ -309,6 +309,7 @@ struct smbc_server *smbc_server(char *server, char *share, /* have to open a new connection */ if (!cli_initialise(&c) || !cli_connect(&c, server_n, &ip)) { + if (c.initialised) cli_shutdown(&c); errno = ENOENT; return NULL; }