Prevent potential null pointer dereference
This null-check resolves a potential issue detected by static analysis. It might be the case, that crash never happens due to the way this static function is used at the moment, and because DYNFLG_CHANGED is being cleared in dnew->genreg->Clear() few lines before, but the crash might still happen if initial state of flags is inconsistent or surrounding code will be changed even a little bit. This nullcheck makes the code more robust at no performance penalty.
This commit is contained in:
parent
2487242011
commit
4a01b6a00d
2 changed files with 4 additions and 2 deletions
|
@ -439,7 +439,8 @@ static void gen_synchreg(DynReg * dnew,DynReg * dsynch) {
|
|||
if ((dnew->flags ^ dsynch->flags) & DYNFLG_CHANGED) {
|
||||
/* Ensure the changed value gets saved */
|
||||
if (dnew->flags & DYNFLG_CHANGED) {
|
||||
dnew->genreg->Save();
|
||||
if (GCC_LIKELY(dnew->genreg != NULL))
|
||||
dnew->genreg->Save();
|
||||
} else dnew->flags|=DYNFLG_CHANGED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,8 @@ static void gen_synchreg(DynReg * dnew,DynReg * dsynch) {
|
|||
if ((dnew->flags ^ dsynch->flags) & DYNFLG_CHANGED) {
|
||||
/* Ensure the changed value gets saved */
|
||||
if (dnew->flags & DYNFLG_CHANGED) {
|
||||
dnew->genreg->Save();
|
||||
if (GCC_LIKELY(dnew->genreg != NULL))
|
||||
dnew->genreg->Save();
|
||||
} else dnew->flags|=DYNFLG_CHANGED;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue