RegexpCompileError leak

This commit is contained in:
James Cherry 2020-04-06 22:19:50 -07:00
parent 2412dbbc0b
commit 5d6faea9e3
2 changed files with 7 additions and 9 deletions

View File

@ -16,6 +16,7 @@
#pragma once
#include <string>
#include "DisallowCopyAssign.hh"
#include "Error.hh"
@ -67,12 +68,12 @@ private:
class RegexpCompileError : public Exception
{
public:
explicit RegexpCompileError(const char *error);
explicit RegexpCompileError(const char *pattern);
virtual ~RegexpCompileError() noexcept {}
virtual const char *what() const noexcept;
private:
const char *error_;
std::string error_;
};
// Simple pattern match

View File

@ -16,13 +16,8 @@
#include "PatternMatch.hh"
#include <string.h>
#include <string>
#include <ctype.h>
#include <tcl.h>
#include "StringUtil.hh"
namespace sta {
using std::string;
@ -117,13 +112,15 @@ PatternMatch::matchNoCase(const char *str) const
RegexpCompileError::RegexpCompileError(const char *pattern) :
Exception()
{
error_ = stringPrint("TCL failed to compile regular expression '%s'.", pattern);
error_ = "TCL failed to compile regular expression '";
error_ += pattern;
error_ =+ "'.";
}
const char *
RegexpCompileError::what() const noexcept
{
return error_;
return error_.c_str();
}
////////////////////////////////////////////////////////////////