mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-05 20:55:47 +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:
@@ -218,11 +218,14 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
|
|||||||
|
|
||||||
/* Data in sock*/
|
/* Data in sock*/
|
||||||
rc = read(sock, buf, bufsize);
|
rc = read(sock, buf, bufsize);
|
||||||
if (rc > 0)
|
if (rc > 0) {
|
||||||
rc = libssh2_channel_write(channel,buf, rc);
|
rc = libssh2_channel_write(channel, buf, rc);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
free(buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(fds);
|
free(fds);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
Reference in New Issue
Block a user