fixed potential null pointer bug

This commit is contained in:
jp9000
2013-12-13 10:24:54 -07:00
parent fa00c6fa47
commit 31dd23cb0d

View File

@@ -247,10 +247,9 @@ void device_load_texture(device_t device, texture_t tex, int unit)
if (!gl_active_texture(GL_TEXTURE0 + unit))
goto fail;
if (cur_tex && cur_tex->gl_target != tex->gl_target)
if (!tex || (cur_tex && cur_tex->gl_target != tex->gl_target))
gl_bind_texture(cur_tex->gl_target, 0);
device->cur_textures[unit] = tex;
param = get_texture_param(device, unit);
if (!param)