Fix crash regression due to ca8c302805f882ed61717bb26efbc141a6991ea7

Crash regression has been inserted by #11258.

The 2GB+ adaptation has forced change in integers saving via TinyXML (now saved indirectly as strings). While the MapPosition part has been already fortified against possible missing session-file items, the Position part not. So implemented likewise the MapPosition way.

Fix #11325, close #11327
This commit is contained in:
xomx 2022-03-02 22:27:56 +01:00 committed by Don Ho
parent c19033c917
commit a419b41ed5

View File

@ -2175,14 +2175,31 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session& s
if (fileName) if (fileName)
{ {
Position position; Position position;
position._firstVisibleLine = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("firstVisibleLine")))); const TCHAR* posStr = (childNode->ToElement())->Attribute(TEXT("firstVisibleLine"));
position._xOffset = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("xOffset")))); if (posStr)
position._startPos = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("startPos")))); position._firstVisibleLine = static_cast<intptr_t>(_ttoi64(posStr));
position._endPos = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("endPos")))); posStr = (childNode->ToElement())->Attribute(TEXT("xOffset"));
position._selMode = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("selMode")))); if (posStr)
position._scrollWidth = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("scrollWidth")))); position._xOffset = static_cast<intptr_t>(_ttoi64(posStr));
position._offset = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("offset")))); posStr = (childNode->ToElement())->Attribute(TEXT("startPos"));
position._wrapCount = static_cast<intptr_t>(_ttoi64((childNode->ToElement())->Attribute(TEXT("wrapCount")))); if (posStr)
position._startPos = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("endPos"));
if (posStr)
position._endPos = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("selMode"));
if (posStr)
position._selMode = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("scrollWidth"));
if (posStr)
position._scrollWidth = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("offset"));
if (posStr)
position._offset = static_cast<intptr_t>(_ttoi64(posStr));
posStr = (childNode->ToElement())->Attribute(TEXT("wrapCount"));
if (posStr)
position._wrapCount = static_cast<intptr_t>(_ttoi64(posStr));
MapPosition mapPosition; MapPosition mapPosition;
const TCHAR* mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDisplayLine")); const TCHAR* mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDisplayLine"));
if (mapPosStr) if (mapPosStr)