dprintf() probably adds a terminating null. If you have only two characters, you will corrupt memory. This can cause all sorts of strange things to happen.
But I suspect that there's also a problem...