Skip to content
Snippets Groups Projects
Commit 1503af41 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #21631: fileutils: don't return pointer to function-local object

The string in question would be destroyed before we used the pointer.
parent 6e2fc70e
No related branches found
No related tags found
No related merge requests found
......@@ -84,10 +84,10 @@ const char *get_program_dir()
}
// FIXME: This should use our real DATADIR
const char *get_data_dir()
std::string
get_data_dir()
{
std::string path = std::string(get_program_dir()) + "/../../share/sflphone/ringtones/";
return path.c_str();
return std::string(get_program_dir()) + "/../../share/sflphone/ringtones/";
}
namespace {
......
......@@ -31,6 +31,8 @@
#ifndef FILEUTILS_H_
#define FILEUTILS_H_
#include <string>
#define PROTECTED_GETENV(str) ({char *envvar_ = getenv((str)); \
envvar_ ? envvar_ : "";})
......@@ -49,7 +51,7 @@ namespace fileutils {
bool check_dir(const char *path);
void set_program_dir(char *program_path);
const char *get_program_dir();
const char *get_data_dir();
std::string get_data_dir();
bool isDirectoryWritable(const std::string &directory);
struct FileHandle {
int fd;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment