0003-Avoid-possible-memory-leak-64-bytes-per-rmtree-call-.patch
application/octet-stream
Filename: 0003-Avoid-possible-memory-leak-64-bytes-per-rmtree-call-.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch 0003
Subject: Avoid possible memory leak (64 bytes) per rmtree call, when can't open a directory.
| File | + | − |
|---|---|---|
| src/common/rmtree.c | 2 | 1 |
From bcdfcbc9b85bf8e0e7c6693a837513e68008f9d2 Mon Sep 17 00:00:00 2001
From: Ranier Vilela <ranier.vf@gmail.com>
Date: Tue, 25 Jul 2023 09:21:34 -0300
Subject: [PATCH 3/4] Avoid possible memory leak (64 bytes) per rmtree call,
when can't open a directory.
Per Coverity.
Author: Ranier Vilela (ranier.vf@gmail.com)
---
src/common/rmtree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/common/rmtree.c b/src/common/rmtree.c
index cd99d3f471..0fdc28fb7f 100644
--- a/src/common/rmtree.c
+++ b/src/common/rmtree.c
@@ -55,7 +55,7 @@ rmtree(const char *path, bool rmtopdir)
bool result = true;
size_t dirnames_size = 0;
size_t dirnames_capacity = 8;
- char **dirnames = palloc(sizeof(char *) * dirnames_capacity);
+ char **dirnames;
dir = OPENDIR(path);
if (dir == NULL)
@@ -64,6 +64,7 @@ rmtree(const char *path, bool rmtopdir)
return false;
}
+ dirnames = (char **) palloc(sizeof(char *) * dirnames_capacity);
while (errno = 0, (de = readdir(dir)))
{
if (strcmp(de->d_name, ".") == 0 ||
--
2.32.0.windows.1