[OpenSim] Sometimes we are given invalid born strings, don't crash!
This commit is contained in:
@@ -194,11 +194,16 @@ void LLPanelAvatarSecondLife::processProperties(void* data, EAvatarProcessorType
|
||||
{
|
||||
using namespace boost::gregorian;
|
||||
int year, month, day;
|
||||
sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d", &month, &day, &year);
|
||||
date birthday(year, month, day), today(day_clock::local_day());
|
||||
std::ostringstream born_on;
|
||||
born_on << pAvatarData->born_on << " (" << today - birthday << ')';
|
||||
childSetValue("born", born_on.str());
|
||||
const auto& born = pAvatarData->born_on;
|
||||
if (!born.empty() && sscanf(born.c_str(),"%d/%d/%d", &month, &day, &year) == 3 // Make sure input is valid
|
||||
&& month > 0 && month <= 12 && day > 0 && day <= 31 && year >= 1400) // Don't use numbers that gregorian will choke on
|
||||
{
|
||||
date birthday(year, month, day), today(day_clock::local_day());
|
||||
std::ostringstream born_on;
|
||||
born_on << pAvatarData->born_on << " (" << today - birthday << ')';
|
||||
childSetValue("born", born_on.str());
|
||||
}
|
||||
else childSetValue("born", born);
|
||||
}
|
||||
|
||||
bool allow_publish = (pAvatarData->flags & AVATAR_ALLOW_PUBLISH);
|
||||
|
||||
Reference in New Issue
Block a user