returning address of local variable or temporary
A function returned the address of a local variable or a temporary. Local variables and temporaries are destroyed when a function returns; consequently the address returned will almost certainly be invalid.
When returning the address of a variable, you should return the address of a global variable or a dynamically allocated variable, which will continue to exist after the function ends.