Please ignore if I'm making a stupid remark, but I've been staring at this part of the code for a while now and can't figure it out (lines 852, 853 and 856).

Line 852 should be moved to below the if block? If not, then I don't understand the if (!m_texture) on line 853. I mean, this will never evaluate to true because either m_texture is not NULL, or when m_texture is NULL you will have already caused a null pointer exception at line 852 when invoking m_texture->Allocate().

Line 853/856. If m_texture is NULL, then why delete it at line 856 if it does not exist anyway?