It crashes when using this function. Well actually, both the functions do what they need to do, but when leaving the function, then the crash happens...
Also worth mentioning: debug version works proper, release gives this crash.