Fix: Pass valid buffer to recv() instead of NULL
Valgrind reports: Syscall param socketcall.recvfrom(buf) points to unaddressable byte(s) at recv (recv.c:28) by xmppclient_end_session (xmppclient.c:57) Address 0x0 is not stack'd, malloc'd or (recently) free'd The recv() call was passing NULL as buffer, which is invalid. Now using a local char variable as discard buffer.
This commit is contained in:
@@ -54,7 +54,7 @@ xmppclient_end_session(XMPPClient *client)
|
||||
|
||||
if (client->sock) {
|
||||
shutdown(client->sock, 2);
|
||||
while (recv(client->sock, NULL, 1, 0) > 0) {}
|
||||
char discard_buf; while (recv(client->sock, &discard_buf, 1, 0) > 0) {}
|
||||
close(client->sock);
|
||||
}
|
||||
free(client->ip);
|
||||
|
||||
Reference in New Issue
Block a user