Memory allocating with new[] should be freed with delete[]
Merge pull request #1812 from nlyan/minor-fixes

Memory allocating with new[] should be freed with delete[]