diff --git a/library/std/src/sys/unix/ext/net/ancillary.rs b/library/std/src/sys/unix/ext/net/ancillary.rs index a94456b4e7a6b..2c91ba70dd0b5 100644 --- a/library/std/src/sys/unix/ext/net/ancillary.rs +++ b/library/std/src/sys/unix/ext/net/ancillary.rs @@ -160,6 +160,8 @@ fn add_to_ancillary_data( previous_cmsg = cmsg; cmsg = libc::CMSG_NXTHDR(&msg, cmsg); cfg_if::cfg_if! { + // Android return the same pointer if it is the last cmsg. + // Therefore, check it if the previous pointer is the same as the current one. if #[cfg(target_os = "android")] { if cmsg == previous_cmsg { break; @@ -430,6 +432,8 @@ impl<'a> Iterator for Messages<'a> { let cmsg = cmsg.as_ref()?; cfg_if::cfg_if! { + // Android return the same pointer if it is the last cmsg. + // Therefore, check it if the previous pointer is the same as the current one. if #[cfg(target_os = "android")] { if let Some(current) = self.current { if eq(current, cmsg) {