c++: Fix null this pointer [PR 98624]