util: Fix memory leak in PatternMatch (#282)
When allocating a new string object in tcl you need increment and then decremenet the ref counter in order for objects to be correctly collected. Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
This commit is contained in:
parent
82fd625199
commit
6d18003c04
|
|
@ -89,7 +89,9 @@ PatternMatch::compileRegexp()
|
|||
anchored_pattern += '$';
|
||||
Tcl_Obj *pattern_obj = Tcl_NewStringObj(anchored_pattern.c_str(),
|
||||
anchored_pattern.size());
|
||||
Tcl_IncrRefCount(pattern_obj);
|
||||
regexp_ = Tcl_GetRegExpFromObj(interp_, pattern_obj, flags);
|
||||
Tcl_DecrRefCount(pattern_obj);
|
||||
if (regexp_ == nullptr && interp_)
|
||||
throw RegexpCompileError(pattern_);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue