Skip to content

Commit

Permalink
Fixed CodeQL gripes with usage of c_str() pointers after the lifetime…
Browse files Browse the repository at this point in the history
… of the std::string objects. (#404)

Co-authored-by: Ed Sabol <[email protected]>
  • Loading branch information
esabol and esabol authored Aug 4, 2024
1 parent 47f232c commit 6816e06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libtest/signal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ bool SignalThread::setup()
{
set_shutdown(SHUTDOWN_RUNNING);

const char * lock_name = random_lock_name().c_str();
lock = sem_open(lock_name, O_CREAT|O_EXCL, S_IRUSR|S_IWUSR, 0);
std::string lock_name = random_lock_name();
lock = sem_open(lock_name.c_str(), O_CREAT|O_EXCL, S_IRUSR|S_IWUSR, 0);
if (lock == SEM_FAILED)
{
Error << errno << ": " << strerror(errno)
Expand Down
4 changes: 2 additions & 2 deletions util/signal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ bool SignalThread::setup()
return false;
}

const char * lock_name = random_lock_name().c_str();
lock = sem_open(lock_name, O_CREAT|O_EXCL, S_IRUSR|S_IWUSR, 0);
std::string lock_name = random_lock_name();
lock = sem_open(lock_name.c_str(), O_CREAT|O_EXCL, S_IRUSR|S_IWUSR, 0);
if (lock == SEM_FAILED) {
std::cerr << "WARNING: sem_open failed(" << strerror(errno) << ")"
<< " when opening lock '" << lock_name << "'." << std::endl;
Expand Down

0 comments on commit 6816e06

Please sign in to comment.