1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 23:32:26 +00:00

input: handle reaching MP_MAX_FDS correctly

Don't dereference fd and increment ictx->num_fds on fail.
This commit is contained in:
shdown 2014-08-30 14:08:13 +04:00 committed by wm4
parent e2ecf3d03d
commit 8ee1bcf1fa

View File

@ -858,17 +858,17 @@ int mp_input_add_fd(struct input_ctx *ictx, int unix_fd, int select,
MP_ERR(ictx, "Too many file descriptors.\n");
} else {
fd = &ictx->fds[ictx->num_fds];
*fd = (struct input_fd){
.log = ictx->log,
.fd = unix_fd,
.select = select,
.read_cmd = read_cmd_func,
.read_key = read_key_func,
.close_func = close_func,
.ctx = ctx,
};
ictx->num_fds++;
}
*fd = (struct input_fd){
.log = ictx->log,
.fd = unix_fd,
.select = select,
.read_cmd = read_cmd_func,
.read_key = read_key_func,
.close_func = close_func,
.ctx = ctx,
};
ictx->num_fds++;
input_unlock(ictx);
return !!fd;
}