mirror of https://github.com/mpv-player/mpv
input: handle reaching MP_MAX_FDS correctly
Don't dereference fd and increment ictx->num_fds on fail.
This commit is contained in:
parent
e2ecf3d03d
commit
8ee1bcf1fa
|
@ -858,7 +858,6 @@ int mp_input_add_fd(struct input_ctx *ictx, int unix_fd, int select,
|
||||||
MP_ERR(ictx, "Too many file descriptors.\n");
|
MP_ERR(ictx, "Too many file descriptors.\n");
|
||||||
} else {
|
} else {
|
||||||
fd = &ictx->fds[ictx->num_fds];
|
fd = &ictx->fds[ictx->num_fds];
|
||||||
}
|
|
||||||
*fd = (struct input_fd){
|
*fd = (struct input_fd){
|
||||||
.log = ictx->log,
|
.log = ictx->log,
|
||||||
.fd = unix_fd,
|
.fd = unix_fd,
|
||||||
|
@ -869,6 +868,7 @@ int mp_input_add_fd(struct input_ctx *ictx, int unix_fd, int select,
|
||||||
.ctx = ctx,
|
.ctx = ctx,
|
||||||
};
|
};
|
||||||
ictx->num_fds++;
|
ictx->num_fds++;
|
||||||
|
}
|
||||||
input_unlock(ictx);
|
input_unlock(ictx);
|
||||||
return !!fd;
|
return !!fd;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue