Uh, this was a crass memory overflow, thank you.  
This should be fine as well:
memset(tmp, 0, sizeof(tmp));