[mdns] handle allocation failure in RxMessage::Init() (#12193)

This commit updates `RxMessage::Init()` to handle failures when
reserving capacity for the questions array. Previously, an allocation
failure would trigger an assertion.

By switching to `SuccessOrExit`, the method can now gracefully handle
the allocation failure by returning an error and dropping the
message. This aligns with the general error handling strategy for
received messages and makes the implementation more robust against
out-of-memory conditions.
This commit is contained in:
Abtin Keshavarzian
2025-12-03 12:40:41 -08:00
committed by GitHub
parent 3335928a5d
commit 32ef52f06a
+1 -1
View File
@@ -4229,7 +4229,7 @@ Error Core::RxMessage::Init(Instance &aInstance,
mStartOffset[kQuestionSection] = offset;
SuccessOrAssert(mQuestions.ReserveCapacity(mRecordCounts.GetFor(kQuestionSection)));
SuccessOrExit(error = mQuestions.ReserveCapacity(mRecordCounts.GetFor(kQuestionSection)));
for (numRecords = mRecordCounts.GetFor(kQuestionSection); numRecords > 0; numRecords--)
{