Skip to content

Commit 4d364ff

Browse files
author
bjjwwang
committed
Read the comments in PullRequest (vibe-kanban 78898480)
#1789 Could you read comments in this PR?
1 parent d70d6fa commit 4d364ff

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

svf/lib/AE/Svfexe/AEDetector.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,23 @@ bool BufOverflowDetector::canSafelyAccessMemory(AbstractState& as, const SVF::SV
479479
SVFIR* svfir = PAG::getPAG();
480480
NodeID value_id = value->getId();
481481

482-
// In multi-entry analysis, some variables may not be initialized as addresses
482+
// Lazy initialization for uninitialized pointer parameters in multi-entry analysis.
483+
// When analyzing a function as an entry point (e.g., not called from main),
484+
// pointer parameters may not have been initialized via AddrStmt.
485+
//
486+
// Example:
487+
// void process_buffer(char* buf, int len) {
488+
// buf[0] = 'a'; // accessing buf
489+
// }
490+
// When analyzing process_buffer as an entry point, 'buf' is a function parameter
491+
// with no AddrStmt, so it has no address information in the abstract state.
492+
// We lazily initialize it to point to the black hole object (BlkPtr), representing
493+
// an unknown but valid memory location. This allows the analysis to continue
494+
// while being conservatively sound.
483495
if (!as[value_id].isAddr())
484496
{
485-
// Conservatively assume safe when we don't have address information
486-
return true;
497+
NodeID blkPtrId = svfir->getBlkPtr();
498+
as[value_id] = AddressValue(AbstractState::getVirtualMemAddress(blkPtrId));
487499
}
488500
for (const auto& addr : as[value_id].getAddrs())
489501
{

0 commit comments

Comments
 (0)