Merge pull request #1360 from sjinks/1.2.4

[1.2.4] Fix valgrind errors
Test case for #1364