1 |
commit: ea744763eb0df6693068d85ea24fa47577c0da0f |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 19 12:14:44 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jan 19 12:14:44 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ea744763 |
7 |
|
8 |
quse: fix Coverity 206564 Resource leak |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
quse.c | 15 ++++++++++----- |
13 |
1 file changed, 10 insertions(+), 5 deletions(-) |
14 |
|
15 |
diff --git a/quse.c b/quse.c |
16 |
index 4a8b89b..f88e298 100644 |
17 |
--- a/quse.c |
18 |
+++ b/quse.c |
19 |
@@ -289,19 +289,24 @@ quse_search_profiles_desc( |
20 |
continue; |
21 |
|
22 |
namelen = strlen(de->d_name); |
23 |
- if (namelen <= 5 || strcmp(de->d_name + namelen - 5, ".desc") != 0) |
24 |
- return false; |
25 |
+ if (namelen <= 5 || strcmp(de->d_name + namelen - 5, ".desc") != 0) { |
26 |
+ ret = false; |
27 |
+ break; |
28 |
+ } |
29 |
|
30 |
snprintf(_quse_getline_buf, _quse_getline_buflen, |
31 |
"profiles/desc/%s", de->d_name); |
32 |
dfd = openat(portdirfd, _quse_getline_buf, O_RDONLY | O_CLOEXEC); |
33 |
- if (dfd == -1) |
34 |
- return false; |
35 |
+ if (dfd == -1) { |
36 |
+ ret = false; |
37 |
+ break; |
38 |
+ } |
39 |
|
40 |
f = fdopen(dfd, "r"); |
41 |
if (f == NULL) { |
42 |
close(fd); |
43 |
- return false; |
44 |
+ ret = false; |
45 |
+ break; |
46 |
} |
47 |
|
48 |
/* remove trailing .desc */ |