1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-31 00:03:08 +03:00

examples/x11.c: fix possible memory leak if read fails

Detected by clang scan in line 224, column 21.
This commit is contained in:
Marc Hoersken
2014-12-27 14:00:48 +01:00
parent 477e609a84
commit 86552bf2bb

View File

@ -218,10 +218,13 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
/* Data in sock*/
rc = read(sock, buf, bufsize);
if (rc > 0)
rc = libssh2_channel_write(channel,buf, rc);
else
if (rc > 0) {
rc = libssh2_channel_write(channel, buf, rc);
}
else {
free(buf);
return -1;
}
}
free(fds);