From: Philippe De Swert <philippedesw...@gmail.com>

ordered_hashmap_steal_first() can return NULL (and this is usually checked
except here), so there is a potential NULL pointer reference.
Thus moving the NULL check to cover both possible allocations of the
ChainCacheItem.

Found with coverity. Fixes: CID#1249723
---
 src/journal/journal-file.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index d06dbc2..1add0c7 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -1384,10 +1384,11 @@ static void chain_cache_put(
                         ci = ordered_hashmap_steal_first(h);
                 else {
                         ci = new(ChainCacheItem, 1);
-                        if (!ci)
-                                return;
                 }
 
+                if (!ci)
+                       return;
+
                 ci->first = first;
 
                 if (ordered_hashmap_put(h, &ci->first, ci) < 0) {
-- 
1.8.3.2

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to