mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 22:37:45 +00:00
[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:
@@ -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--)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user