Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba9eb29

Browse files
committed
Fix low-probability memory leak in regex execution.
After an internal failure in shortest() or longest() while pinning down theexact location of a match, find() forgot to free the DFA structure beforereturning. This is pretty unlikely to occur, since we just successfullyran the "search" variant of the DFA; but it could happen, and it wouldresult in a session-lifespan memory leak since this code uses malloc()directly. Problem seems to have been aboriginal in Spencer's library,so back-patch all the way.In passing, correct a thinko in a comment I added awhile back about themeaning of the "ntree" field.I happened across these issues while comparing our code to Tcl's versionof the library.
1 parentf7eeb32 commitba9eb29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎src/backend/regex/regexec.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ find(struct vars * v,
323323
(chr**)NULL,&hitend);
324324
else
325325
end=longest(v,d,begin,v->stop,&hitend);
326-
NOERR();
326+
if (ISERR())
327+
{
328+
freedfa(d);
329+
returnv->err;
330+
}
327331
if (hitend&&cold==NULL)
328332
cold=begin;
329333
if (end!=NULL)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp