Fixed a crash and memory leak on the ribbon code

OpenGL needs to unlock buffers on inverse order to work.
Merge pull request #1004 from Lopuska/patch-1

Fixed a crash and memory leak on the ribbon code