mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
rcinput: fix corrupted iterator on input device hot-unplug
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -1305,7 +1305,10 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<in_dev>::iterator i = indev.begin(); i != indev.end(); ++i) {
|
||||
/* iterate backwards or the vector will be corrupted by the indev.erase(i) */
|
||||
std::vector<in_dev>::iterator i = indev.end();
|
||||
while (i != indev.begin()) {
|
||||
--i;
|
||||
if (((*i).fd != -1) && (FD_ISSET((*i).fd, &rfds))) {
|
||||
uint64_t now_pressed = 0;
|
||||
t_input_event ev;
|
||||
@@ -1317,7 +1320,7 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6
|
||||
if (errno == ENODEV) {
|
||||
/* hot-unplugged? */
|
||||
::close((*i).fd);
|
||||
indev.erase(i);
|
||||
i = indev.erase(i);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user