Fixes potential memory leak when the texture cannot be created