1 |
commit: e55f582c4c129ece9037575135a95f98a91a210f |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Aug 17 14:31:16 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 17 14:31:16 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e55f582c |
7 |
|
8 |
qlop: work around Coverity complaints |
9 |
|
10 |
Check/search once for colons, it is a bit brittle to assume a colon was |
11 |
found, even though in this case it should have always succeeded. |
12 |
|
13 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
14 |
|
15 |
qlop.c | 19 +++++++++---------- |
16 |
1 file changed, 9 insertions(+), 10 deletions(-) |
17 |
|
18 |
diff --git a/qlop.c b/qlop.c |
19 |
index 47ef83d..385613a 100644 |
20 |
--- a/qlop.c |
21 |
+++ b/qlop.c |
22 |
@@ -1249,27 +1249,26 @@ static array_t *probe_proc(array_t *atoms) |
23 |
} else if ((size_t)rpathlen > sizeof(".log") && |
24 |
strcmp(rpath + rpathlen - |
25 |
(sizeof(".log") - 1), ".log") == 0 && |
26 |
- (p = strchr(rpath, ':')) != NULL && |
27 |
- (p = strchr(p + 1, ':')) != NULL && |
28 |
(p = strrchr(rpath, '/')) != NULL) |
29 |
{ |
30 |
char *q; |
31 |
|
32 |
p++; /* skip / */ |
33 |
- q = strchr(p, ':'); /* checked above to exist */ |
34 |
- *q++ = '/'; |
35 |
- q = strchr(q, ':'); /* checked above to exist */ |
36 |
- *q = '\0'; |
37 |
- |
38 |
- atom = atom_explode(p); |
39 |
+ if ((q = strchr(p, ':')) != NULL) { |
40 |
+ *q++ = '/'; |
41 |
+ if ((q = strchr(q, ':')) != NULL) { |
42 |
+ *q = '\0'; |
43 |
+ atom = atom_explode(p); |
44 |
+ } |
45 |
+ } |
46 |
} |
47 |
|
48 |
+ if (atom == NULL) |
49 |
+ continue; |
50 |
if (atom->CATEGORY == NULL || atom->P == NULL) { |
51 |
atom_implode(atom); |
52 |
continue; |
53 |
} |
54 |
- if (atom == NULL) |
55 |
- continue; |
56 |
|
57 |
xarraypush_ptr(ret_atoms, atom); |
58 |
} |