This is an archive of the discontinued LLVM Phabricator instance.

Guard against self-assignment in InputArgList
ClosedPublic

Authored by andrew.w.kaylor on Aug 16 2023, 5:06 PM.

Details

Summary

The InputArgList move assignment operator releases memory before copying fields, but it doesn't check against self-assignment. I haven't seen the self-assignment happen, but it doesn't look safe.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 5:06 PM
andrew.w.kaylor requested review of this revision.Aug 16 2023, 5:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 5:06 PM

Any chance of adding unit test coverage for this?

llvm/include/llvm/Option/ArgList.h
428–429

I'd probably reduce indentation with an early return, even if it means duplicating the (fairly simple) return expression. But no big deal either way.

Add unit test and refactor to use early return

dblaikie accepted this revision.Aug 24 2023, 1:16 PM

awesome :)

This revision is now accepted and ready to land.Aug 24 2023, 1:16 PM
This revision was landed with ongoing or failed builds.Aug 24 2023, 2:45 PM
This revision was automatically updated to reflect the committed changes.