]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/port: add BUG_ON on impossible condition
authorShivani Bhardwaj <shivani@oisf.net>
Tue, 5 Aug 2025 10:32:16 +0000 (16:02 +0530)
committerVictor Julien <victor@inliniac.net>
Thu, 7 Aug 2025 19:12:38 +0000 (21:12 +0200)
to assist Coverity in assessing the state of x correctly.

src/detect-engine-port.c

index 7d8b15a22c3d55ce1f74d3df6a19884bc257e927..07b0ebc13a3d1bbe41e065c52e2fba21f62ddd8e 100644 (file)
@@ -807,6 +807,7 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx,
         } else if (!o_set && s[u] == '!') {
             SCLogDebug("negation encountered");
             n_set = 1;
+            BUG_ON(x == 0); /* always false; added to guide static code analyzers like Coverity */
             x--;
         } else if (s[u] == '[') {
             if (!o_set) {