diff --git a/example/scp_write.c b/example/scp_write.c index c8623a5..c8201f1 100644 --- a/example/scp_write.c +++ b/example/scp_write.c @@ -197,6 +197,8 @@ int main(int argc, char *argv[]) #else close(sock); #endif + if (local) + fclose(local); fprintf(stderr, "all done\n"); return 0; } diff --git a/example/sftp_RW_nonblock.c b/example/sftp_RW_nonblock.c index 69a6fa1..56fb339 100644 --- a/example/sftp_RW_nonblock.c +++ b/example/sftp_RW_nonblock.c @@ -283,6 +283,8 @@ int main(int argc, char *argv[]) #else close(sock); #endif + if (tempstorage) + fclose(tempstorage); printf("all done\n"); return 0; } diff --git a/example/sftp_write.c b/example/sftp_write.c index 02c4654..ca65b82 100644 --- a/example/sftp_write.c +++ b/example/sftp_write.c @@ -184,12 +184,10 @@ int main(int argc, char *argv[]) } while (rc > 0); } while (1); - fclose(local); libssh2_sftp_close(sftp_handle); libssh2_sftp_shutdown(sftp_session); - shutdown: - +shutdown: libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing"); libssh2_session_free(session); @@ -199,6 +197,8 @@ int main(int argc, char *argv[]) #else close(sock); #endif -printf("all done\n"); + if (local) + fclose(local); + printf("all done\n"); return 0; } diff --git a/example/x11.c b/example/x11.c index 5265b82..793833d 100644 --- a/example/x11.c +++ b/example/x11.c @@ -121,11 +121,16 @@ static void x11_callback(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, /* Connect to the local unix domain */ ptr = strrchr(display, ':'); temp_buff = (char *) calloc(strlen(ptr+1), sizeof(char)); + if (!temp_buff) { + perror("calloc"); + return; + } memcpy(temp_buff, ptr+1, strlen(ptr+1)); display_port = atoi(temp_buff); + free(temp_buff); - sock = socket(AF_UNIX,SOCK_STREAM, 0); - if (sock <0) + sock = socket(AF_UNIX, SOCK_STREAM, 0); + if (sock < 0) return; memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX;