mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-06 06:46:29 -04:00
rtp-sap: handle uninitialized avail
When the ioctl fails, avail might be uninitialized. Check the ioctl return value and handle invalid avail.
This commit is contained in:
parent
c4a2f9b480
commit
d32a21c4ee
1 changed files with 5 additions and 5 deletions
|
|
@ -591,13 +591,13 @@ static bool update_ts_refclk(struct impl *impl)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Read if something is left in the socket
|
||||
int avail;
|
||||
int avail = 0;
|
||||
uint8_t tmp;
|
||||
|
||||
ioctl(impl->ptp_fd, FIONREAD, &avail);
|
||||
pw_log_debug("Flushing stale data: %u bytes", avail);
|
||||
while (avail-- && read(impl->ptp_fd, &tmp, 1));
|
||||
if (ioctl(impl->ptp_fd, FIONREAD, &avail) == 0 && avail > 0) {
|
||||
pw_log_debug("Flushing stale data: %d bytes", avail);
|
||||
while (avail-- > 0 && read(impl->ptp_fd, &tmp, 1) == 1);
|
||||
}
|
||||
|
||||
struct ptp_management_msg req;
|
||||
spa_zero(req);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue