Skip to content

Commit

Permalink
More secure work with weak pointers. Refs #214.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhop committed Aug 23, 2024
1 parent b928038 commit f2be044
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/addon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,18 @@ const StrVal &WrappedRE2::prepareArgument(const v8::Local<v8::Value> &arg, bool
{
size_t startFrom = ignoreLastIndex ? 0 : lastIndex;

if (lastString == arg && !node::Buffer::HasInstance(arg) && !lastCache.IsEmpty())
if (!lastString.IsEmpty())
{
// we have a properly cached string
lastString.ClearWeak();
}
if (!lastCache.IsEmpty())
{
lastCache.ClearWeak();
}

if (lastString == arg && !node::Buffer::HasInstance(arg) && !lastCache.IsEmpty())
{
// we have a properly cached string
lastStringValue.setIndex(startFrom);
return lastStringValue;
}
Expand Down

0 comments on commit f2be044

Please sign in to comment.