Fixing memory leak introduced by b552200 (closes #3050)
Merge pull request #3084 from andrsd/fix-memory-leak

Fixing memory leak introduced by b552200 (closes #3050)