Fixed NULL-dereference error and ZTS build.