Fixed segfaults with ZTS on PHP 5.6

Found through Travis, it's already being useful!