]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: Improve testACLMaxUserIP NULL checks
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 15 Jan 2014 01:59:19 +0000 (14:59 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 15 Jan 2014 01:59:19 +0000 (14:59 +1300)
  Detected by Coverity Scan. Issue 1140358.

src/tests/testACLMaxUserIP.cc

index ed9fe7529cc30e2a759e848d392b629aee3b027b..542aa5c813a9b2d8d2a27dcc97a97a7f0776a64f 100644 (file)
@@ -41,12 +41,13 @@ testACLMaxUserIP::testParseLine()
     ACL::ParseAclLine(LegacyParser, &anACL);
     ACLMaxUserIP *maxUserIpACL = dynamic_cast<ACLMaxUserIP *>(anACL);
     CPPUNIT_ASSERT(maxUserIpACL);
-
-    /* we want a maximum of one, and strict to be true */
-    CPPUNIT_ASSERT_EQUAL(1, maxUserIpACL->getMaximum());
-    CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL->getStrict());
-    /* the acl must be vaid */
-    CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL->valid());
+    if (maxUserIpACL) {
+        /* we want a maximum of one, and strict to be true */
+        CPPUNIT_ASSERT_EQUAL(1, maxUserIpACL->getMaximum());
+        CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL->getStrict());
+        /* the acl must be vaid */
+        CPPUNIT_ASSERT_EQUAL(true, maxUserIpACL->valid());
+    }
     delete anACL;
     xfree(line);
 }