]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: fix assertion in Store unit tests
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 21 Aug 2015 09:43:53 +0000 (02:43 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 21 Aug 2015 09:43:53 +0000 (02:43 -0700)
The old Squid String implementation cannot handle appending nullptr or
negative lengths. So if the test code using CapturingStoreEntry ever
tries to append such it will crash instead of working like a StoreEntry
should.

src/tests/CapturingStoreEntry.h

index 486ba5d7ba2a0bd591cecf271568c33986a4d3c4..e263e99d88e603a1b698259249c45205858159f6 100644 (file)
@@ -33,6 +33,8 @@ public:
     }
 
     virtual void append(char const * buf, int len) {
+        if (!buf || len < 0) // old 'String' can't handle these cases
+            return;
         _appended_text.append(buf, len);
     }
 };