make code more safe (RT#79458)
Merge pull request #31 from chorny/rt-79458

make code more safe by avoiding undefined behavior (RT#79458)