Skip to content

Commit 03c34a9

Browse files
Abseil Teamcopybara-github
authored andcommitted
Fix a bug where EOF resulted in infinite loop.
PiperOrigin-RevId: 706806310 Change-Id: I15f7d8cb57c0dfb7f6bb35b623347e386af032cd
1 parent 82d40e6 commit 03c34a9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

absl/debugging/symbolize_elf.inc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,9 @@ static ABSL_ATTRIBUTE_NOINLINE bool GetSectionHeaderByType(
541541
(buf_bytes > num_bytes_left) ? num_bytes_left : buf_bytes;
542542
const off_t offset = sh_offset + static_cast<off_t>(i * sizeof(buf[0]));
543543
const ssize_t len = file->ReadFromOffset(buf, num_bytes_to_read, offset);
544-
if (len < 0) {
545-
ABSL_RAW_LOG(
546-
WARNING,
547-
"Reading %zu bytes from offset %ju returned %zd which is negative.",
548-
num_bytes_to_read, static_cast<intmax_t>(offset), len);
544+
if (len <= 0) {
545+
ABSL_RAW_LOG(WARNING, "Reading %zu bytes from offset %ju returned %zd.",
546+
num_bytes_to_read, static_cast<intmax_t>(offset), len);
549547
return false;
550548
}
551549
if (static_cast<size_t>(len) % sizeof(buf[0]) != 0) {

0 commit comments

Comments
 (0)