Properly allocate room for the null terminator.

Also properly delete the StorageDirectory path.
Merge branch 'valgrind_detected_leaks'