Fix segfault while creating texture