From 3a2c12889e60ed903e7c3c5d99baa04ed23f3221 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Mon, 21 Oct 2013 10:53:16 -0700 Subject: [PATCH] Use a scoped_ptr to avoid FileFilter leaks. --- main.cc | 8 ++++---- store.cc | 2 +- store.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/main.cc b/main.cc index 9734521..742af6c 100644 --- a/main.cc +++ b/main.cc @@ -850,8 +850,8 @@ int main(int argc, char *argv[]) dbmeta_filename += backup_scheme + "-"; dbmeta_filename += timestamp + ".meta" + filter_extension; RemoteFile *dbmeta_file = remote->alloc_file(dbmeta_filename, "meta"); - FileFilter *dbmeta_filter = FileFilter::New(dbmeta_file->get_fd(), - filter_program); + scoped_ptr dbmeta_filter(FileFilter::New(dbmeta_file->get_fd(), + filter_program)); if (dbmeta_filter == NULL) { fprintf(stderr, "Unable to open descriptor output file: %m\n"); return 1; @@ -899,8 +899,8 @@ int main(int argc, char *argv[]) RemoteFile *descriptor_file = remote->alloc_file(desc_filename, "snapshots"); - FileFilter *descriptor_filter = FileFilter::New(descriptor_file->get_fd(), - signature_filter.c_str()); + scoped_ptr descriptor_filter( + FileFilter::New(descriptor_file->get_fd(), signature_filter.c_str())); if (descriptor_filter == NULL) { fprintf(stderr, "Unable to open descriptor output file: %m\n"); return 1; diff --git a/store.cc b/store.cc index ba6d692..a77d64a 100644 --- a/store.cc +++ b/store.cc @@ -64,7 +64,7 @@ Tarfile::Tarfile(RemoteFile *file, const string &segment) assert(sizeof(struct tar_header) == TAR_BLOCK_SIZE); this->file = file; - this->filter = FileFilter::New(file->get_fd(), filter_program); + this->filter.reset(FileFilter::New(file->get_fd(), filter_program)); } Tarfile::~Tarfile() diff --git a/store.h b/store.h index 122a4ac..ab5f8e9 100644 --- a/store.h +++ b/store.h @@ -33,6 +33,7 @@ #include #include +#include "cumulus.h" #include "localdb.h" #include "remote.h" #include "ref.h" @@ -122,7 +123,7 @@ private: std::string segment_name; RemoteFile *file; - FileFilter *filter; + scoped_ptr filter; // Write data to the tar file void tar_write(const char *data, size_t size); -- 2.20.1