Misc memory related fixes.

- No need for check the ptr to be different than 0 when using delete:
  delete 0 is a noop.
- Fix minor leak, reported by valgrind and in CMSSW since ~ever,
  where a new [] was not followed by a delete[].
Merge pull request #630 from ktf/fix-unmatched-array-delete

Misc memory related fixes.