diff options
| author | Jonathan "Geenz" Goodman <geenz@lindenlab.com> | 2026-05-20 12:05:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-20 12:05:18 -0400 |
| commit | 40cd1617a6a663fb921265101307454b490ec4ba (patch) | |
| tree | 2f13741295c385172364e3fa940d7591f32fac4e /indra/newview/lleventpoll.cpp | |
| parent | 9c2ee024bef564ebb6e2e8942b43ffae1d99232c (diff) | |
| parent | df844170600608b37c2725f7a263f1de3b055618 (diff) | |
Merge branch 'develop' into geenz/26.3-to-develop
Diffstat (limited to 'indra/newview/lleventpoll.cpp')
| -rw-r--r-- | indra/newview/lleventpoll.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 9eddec55c5..836ff63429 100644 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -331,26 +331,51 @@ namespace Details { // LLSD is too smart for it's own good and may act like a smart // pointer for the content of (*i), so instead of passing (*i) - // pass a prepared name and move ownership of "body", - // as we are not going to need "body" anywhere else. + // pass a prepared name and copy the body std::string msg_name = (*i)["message"].asString(); - // WARNING: This is a shallow copy! - // If something still retains the data (like in httpAdapter?) this might still - // result in a crash, if it does appear to be the case, make a deep copy or - // convert data to string and pass that string. - const LLSD body = (*i)["body"]; - (*i)["body"].clear(); - work = [this, msg_name, body]() + // Create a deep copy using binary serialization + try { - handleMessage(msg_name, body); - }; + std::stringstream body_stream; + LLSDSerialize::toBinary((*i)["body"], body_stream); + std::string body_str = body_stream.str(); + (*i)["body"].clear(); + work = [this, msg_name, body_str]() + { + try + { + LLSD body; + std::istringstream istr(body_str); + LLSDSerialize::fromBinary(body, istr, body_str.size()); + handleMessage(msg_name, body); + } + catch (std::bad_alloc&) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS("LLCoros") << "Bad memory allocation in handleMessage() for " << msg_name << LL_ENDL; + } + }; + } + catch (std::bad_alloc&) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS("LLCoros") << "Bad memory allocation in eventPollCoro for " << msg_name << LL_ENDL; + } } main_queue->post(work); } else { - handleMessage(*i); + try + { + handleMessage(*i); + } + catch (std::bad_alloc&) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS("LLCoros") << "Bad memory allocation in handleMessage() for " << (*i)["message"].asString() << LL_ENDL; + } } } } |
