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

Commitf1e9f6b

Browse files
committed
Avoid memory leak in rmtree() when path cannot be opened
An allocation done for the directory names to recurse into for theirdeletion was done before OPENDIR(), so, assuming that a failure happens,this could leak a bit of memory.Author: Ranier VilelaReviewed-by: Daniel GustafssonDiscussion:https://postgr.es/m/CAEudQAoN3-2ZKBALThnEk_q2hu8En5A0WG9O+5siJTQKVZzoWQ@mail.gmail.com
1 parentbf22792 commitf1e9f6b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎src/common/rmtree.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ rmtree(const char *path, bool rmtopdir)
5555
boolresult= true;
5656
size_tdirnames_size=0;
5757
size_tdirnames_capacity=8;
58-
char**dirnames=palloc(sizeof(char*)*dirnames_capacity);
58+
char**dirnames;
5959

6060
dir=OPENDIR(path);
6161
if (dir==NULL)
@@ -64,6 +64,8 @@ rmtree(const char *path, bool rmtopdir)
6464
return false;
6565
}
6666

67+
dirnames= (char**)palloc(sizeof(char*)*dirnames_capacity);
68+
6769
while (errno=0, (de=readdir(dir)))
6870
{
6971
if (strcmp(de->d_name,".")==0||

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp