returning a pointer now seems to work. We're not corrupting the memory anymore since *buf is declared globally