Fixed a crash and memory leak on the ribbon code

OpenGL needs to unlock buffers on inverse order to work.