fix #20823: Possible access violation
Merge pull request #303 from AntonioBL/fix_possible_access_violation

fix #20823: Possible access violation