check for active_thread != NULL in syscalls.c before using it

fixes #498
Merge pull request #588 from LudwigOrtmann/issue_498

check for active_thread != NULL in syscalls.c before using it