Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Null deref in Update()

A topic by Draque created Feb 14, 2026 Views: 124 Replies: 1
Viewing posts 1 to 2

At the end of the Update() method in the SuperTextMesh class, there's the possibility of a null deref if the rect transform has no parent. I know this is a pretty weird scenario, but it managed to come up in my work, so I thought I would just toss it up here! Including changes for completeness. Also, I wasn't completely sure whether a null value should result in a true or false here for the parent changed flag.


// if(uiMode && (tr.hasChanged || tr.parent.hasChanged)) // ORIGINAL
if (uiMode && (tr.hasChanged || (tr.parent != null && tr.parent.hasChanged))) // DRAQUE
{
    if(tr.hasChanged) tr.hasChanged = false;
    // if(tr.parent.hasChanged) tr.parent.hasChanged = false; // ORIGINAL
    if (tr.parent != null && tr.parent.hasChanged) tr.parent.hasChanged = false; // DRAQUE
    //Debug.Log(this.name + " detected OTHER rect change!");
    CheckRectChange();
}

Developer

Right, this could come up with STM alone in a UI prefab, huh... oh, got it fixed, will push in the next update!