From c96415626ebd37bb1299701b1df57b696858efc9 Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Thu, 20 Jun 2024 11:57:29 +0100 Subject: [PATCH] guard against @connected falling below zero Signed-off-by: Jake Smith --- common/workunit/wujobq.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/workunit/wujobq.cpp b/common/workunit/wujobq.cpp index f7b5d9c286d..99c02da2fe7 100644 --- a/common/workunit/wujobq.cpp +++ b/common/workunit/wujobq.cpp @@ -1128,9 +1128,11 @@ class CJobQueue: public CJobQueueBase, implements IJobQueue ForEachQueue(qd) { IPropertyTree *croot = queryClientRootSession(*qd); - unsigned newConnectedCount = croot->getPropInt64("@connected",0)-1; - if (newConnectedCount) - croot->setPropInt64("@connected", newConnectedCount); + unsigned connectedCount = croot->getPropInt64("@connected"); + if (connectedCount) // should never be 0, but guard JIC + connectedCount--; + if (connectedCount) + croot->setPropInt64("@connected", connectedCount); else qd->root->removeTree(croot); }