Skip to content

Commit aba885c

Browse files
committed
Fix use-after-frees in unix_platform.hpp
1 parent cbc0579 commit aba885c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

backend/src/unix_platform.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ class UnixPlatform : public AbstractPlatform
6161
int err;
6262
struct stat file_stat;
6363

64-
err = stat(this->path().c_str(), &file_stat);
64+
const string &path = this->path();
65+
66+
err = stat(path.c_str(), &file_stat);
6567
if (err == -1)
6668
throw runtime_error("stat() failed");
6769

@@ -75,10 +77,10 @@ class UnixPlatform : public AbstractPlatform
7577
int err;
7678
int fd;
7779

78-
const char *path = this->path().c_str();
80+
const string &path = this->path();
7981

8082
// Open the file.
81-
fd = open(path, O_RDONLY, 0);
83+
fd = open(path.c_str(), O_RDONLY, 0);
8284
if (fd < 0)
8385
throw runtime_error(str(boost::format("fix_permissions: open() failed: %d.") % errno));
8486

0 commit comments

Comments
 (0)