Fixed a memory leak in buffer.c on failure.
Added SG_ASSERT(x,msg) and an assert to texture.c.
Fixed a minor bug (UB in theory) in mouse handling.