Skip to content

Fix the lifetime of progam_iter items#82

Merged
nrc merged 1 commit intonrc:masterfrom
teskje:fix-program-iter-lifetime
Nov 3, 2023
Merged

Fix the lifetime of progam_iter items#82
nrc merged 1 commit intonrc:masterfrom
teskje:fix-program-iter-lifetime

Conversation

@teskje
Copy link
Contributor

@teskje teskje commented Jul 13, 2023

The ProgramHeader objects produced by ElfFile::program_iter should have the same lifetime as the ElfFile, i.e. the lifetime of the input data. Prior to this PR, they instead had the shorter of a) the ElfFile lifetime and b) the &self reference lifetime, making code dealing with these ProgramHeaders awkward to write.

This PR fixes the lifetime issue by making the lifetime annotations the same as for ElfFile::section_iter.

It seems like the issue was originally introduced in #69. That PR also annotates section_iter correctly, so I'm unsure why a different approach was chosen for program_iter.

The `ProgramHeader` objects produced by `ElfFile::program_iter` should
have the same lifetime as the `ElfFile`, i.e. the lifetime of the input
data. Prior to this commit, they instead had the shorter of a) the
`ElfFile` lifetime and b) the `&self` reference lifetime, making code
dealing with these `ProgramHeader`s awkward to write.

This commit fixes the lifetime issue by making the lifetime annotations
the same as for `ElfFile::section_iter`.
@teskje teskje marked this pull request as ready for review July 13, 2023 12:43
Copy link
Owner

@nrc nrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nrc nrc merged commit 5b77c17 into nrc:master Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants