[cppcheck] Fix memory leak.
[cppcheck] Fix out of bounds writes.
Merge pull request #4 from Oppen/master

Some memory related bug-fixes.
Add gitignore file