[PATCH] D135449: [Object] Prevent null pointer dereference in BigArchiveMemberHeader
Victor Campos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 07:56:12 PDT 2022
vhscampos created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
vhscampos requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The pointer argument Err from BigArchiveMemberHeader's constructor can
be null. This pointer was dereferenced without any null checks.
This patch adds a check to avoid a null dereference.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135449
Files:
llvm/lib/Object/Archive.cpp
Index: llvm/lib/Object/Archive.cpp
===================================================================
--- llvm/lib/Object/Archive.cpp
+++ llvm/lib/Object/Archive.cpp
@@ -136,8 +136,11 @@
return;
ErrorAsOutParameter ErrAsOutParam(Err);
- if (Size < getSizeOf())
- *Err = createMemberHeaderParseError(this, RawHeaderPtr, Size);
+ if (Size < getSizeOf()) {
+ Error SubErr = createMemberHeaderParseError(this, RawHeaderPtr, Size);
+ if (Err)
+ *Err = std::move(SubErr);
+ }
}
// This gets the raw name from the ArMemHdr->Name field and checks that it is
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135449.466078.patch
Type: text/x-patch
Size: 582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221007/227e2399/attachment.bin>
More information about the llvm-commits
mailing list