Looking into the function alloc_buf_gc() in file buffer.c, it returns a struct buffer, which seems to me is allocated on the stack, which is causing an issue, I believe, since the function calling alloc_buf_gc() will work on a buffer which becomes garbage.
Please confirm I am not missing something. Thanks, Tiran