1.1 --- a/libfsserver/include/fsserver/host_directory_accessor.h Wed Oct 13 00:51:40 2021 +0200
1.2 +++ b/libfsserver/include/fsserver/host_directory_accessor.h Sat Oct 16 00:22:38 2021 +0200
1.3 @@ -30,7 +30,7 @@
1.4 class HostDirectoryAccessor : public DirectoryAccessor
1.5 {
1.6 protected:
1.7 - const char *_path;
1.8 + char *_path;
1.9
1.10 public:
1.11 explicit HostDirectoryAccessor(const char *path);
2.1 --- a/libfsserver/lib/directories/host_directory_accessor.cc Wed Oct 13 00:51:40 2021 +0200
2.2 +++ b/libfsserver/lib/directories/host_directory_accessor.cc Sat Oct 16 00:22:38 2021 +0200
2.3 @@ -20,6 +20,8 @@
2.4 */
2.5
2.6 #include <dirent.h>
2.7 +#include <stdlib.h>
2.8 +#include <string.h>
2.9
2.10 #include <fsclient/client.h>
2.11
2.12 @@ -27,15 +29,23 @@
2.13
2.14
2.15
2.16 +/* Initialise the accessor, copying the path. */
2.17 +
2.18 HostDirectoryAccessor::HostDirectoryAccessor(const char *path)
2.19 -: _path(path)
2.20 {
2.21 + _path = strdup(path);
2.22 }
2.23
2.24 +/* Release the copied path upon deletion. */
2.25 +
2.26 HostDirectoryAccessor::~HostDirectoryAccessor()
2.27 {
2.28 + if (_path != NULL)
2.29 + free(_path);
2.30 }
2.31
2.32 +/* Write directory entries to the given 'writer'. */
2.33 +
2.34 void HostDirectoryAccessor::read_directory(file_t *writer)
2.35 {
2.36 DIR *dir = opendir(_path);