Yes. A temporary lasts until the end of the full expression that creates it. In this case, the full expression is the entire statement, so it will last until after the function returns.
Make sure the function doesn't store a pointer or reference to the buffer anywhere, since that would be invalidated shortly after it returns.