Fix use-after-free issues when client disconnects
This commit is contained in:
parent
9b76ad5dbc
commit
74838ecc55
1 changed files with 6 additions and 3 deletions
|
@ -651,8 +651,10 @@ client_data_read(client_t *c)
|
|||
int r, cr = 0, i;
|
||||
char buf[100];
|
||||
|
||||
if(space < 1)
|
||||
if(space < 1) {
|
||||
client_teardown(c, EBADMSG);
|
||||
return;
|
||||
}
|
||||
|
||||
r = read(c->c_fd, c->c_input_buf + c->c_input_buf_ptr, space);
|
||||
if(r < 0) {
|
||||
|
@ -701,12 +703,13 @@ client_socket_callback(int events, void *opaque, int fd)
|
|||
{
|
||||
client_t *c = opaque;
|
||||
|
||||
if(events & DISPATCH_ERR)
|
||||
if(events & DISPATCH_ERR) {
|
||||
client_teardown(c, ECONNRESET);
|
||||
return;
|
||||
}
|
||||
|
||||
if(events & DISPATCH_READ)
|
||||
client_data_read(c);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue