Fix some memory errors

I fixed some potential memory errors on window creation on Linux and on music opening.

*Tested on Linux Mint 15 x64 and Archlinux x64*