buffer overrun errors
resource leak
Merge pull request #1047 from JoesCat/master

leaks, buffer overrun