Yeah, that works for making sure the machine isn't constantly crashing.
Although from a security point of view it's still very bad. Every compiler / JIT has bugs, and bugs that let you write to random or arbitrary memory adresses are a rather common kind.
Doesn't really matter for a hobby project though