# HG changeset patch # User Paul Boddie # Date 1634336558 -7200 # Node ID 16fba513c761425cefa0f096ad44effd22edb82b # Parent b8bbb7ab64fefac4da924fd8ae15bd8a4f8f3faa Fixed host directory access, taking a copy of the directory path. diff -r b8bbb7ab64fe -r 16fba513c761 libfsserver/include/fsserver/host_directory_accessor.h --- a/libfsserver/include/fsserver/host_directory_accessor.h Wed Oct 13 00:51:40 2021 +0200 +++ b/libfsserver/include/fsserver/host_directory_accessor.h Sat Oct 16 00:22:38 2021 +0200 @@ -30,7 +30,7 @@ class HostDirectoryAccessor : public DirectoryAccessor { protected: - const char *_path; + char *_path; public: explicit HostDirectoryAccessor(const char *path); diff -r b8bbb7ab64fe -r 16fba513c761 libfsserver/lib/directories/host_directory_accessor.cc --- a/libfsserver/lib/directories/host_directory_accessor.cc Wed Oct 13 00:51:40 2021 +0200 +++ b/libfsserver/lib/directories/host_directory_accessor.cc Sat Oct 16 00:22:38 2021 +0200 @@ -20,6 +20,8 @@ */ #include +#include +#include #include @@ -27,15 +29,23 @@ +/* Initialise the accessor, copying the path. */ + HostDirectoryAccessor::HostDirectoryAccessor(const char *path) -: _path(path) { + _path = strdup(path); } +/* Release the copied path upon deletion. */ + HostDirectoryAccessor::~HostDirectoryAccessor() { + if (_path != NULL) + free(_path); } +/* Write directory entries to the given 'writer'. */ + void HostDirectoryAccessor::read_directory(file_t *writer) { DIR *dir = opendir(_path);