mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-16 21:37:49 -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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read if something is left in the socket
|
int avail = 0;
|
||||||
int avail;
|
|
||||||
uint8_t tmp;
|
uint8_t tmp;
|
||||||
|
|
||||||
ioctl(impl->ptp_fd, FIONREAD, &avail);
|
if (ioctl(impl->ptp_fd, FIONREAD, &avail) == 0 && avail > 0) {
|
||||||
pw_log_debug("Flushing stale data: %u bytes", avail);
|
pw_log_debug("Flushing stale data: %d bytes", avail);
|
||||||
while (avail-- && read(impl->ptp_fd, &tmp, 1));
|
while (avail-- > 0 && read(impl->ptp_fd, &tmp, 1) == 1);
|
||||||
|
}
|
||||||
|
|
||||||
struct ptp_management_msg req;
|
struct ptp_management_msg req;
|
||||||
spa_zero(req);
|
spa_zero(req);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue