When I ran this in the debugger, I got an access violation after a few iterations in that while loop.
I think you need to add the following after line 35 since you were trying to access memory that wasn't allocated to you yet: resultBuf.reserve(buf.size() + argBuf.size() );
Second, I think that the problem lies in the fact that the object that you create in line 46 is destroyed at the end of the function. That means that str3 gets nothing.