]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix memory leak and parse handling error introduced by r15024.
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Tue, 14 Feb 2017 02:03:27 +0000 (15:03 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 14 Feb 2017 02:03:27 +0000 (15:03 +1300)
* Do not leak Note::Value::Value::valueFormat.
* Throw if annotation value parsing failures.

Detected by Coverity Scan:
 * CID 1399758:  Error handling issues (CHECKED_RETURN)
 * CID 1399759:  Resource leaks (CTOR_DTOR_LEAK)

src/Notes.cc

index d424489b4bb67645ae8b8bde007ff79818c84b7e..c1b25bc679f4f1b3aaf5341448cbf73200888c81 100644 (file)
@@ -28,6 +28,7 @@
 Note::Value::~Value()
 {
     aclDestroyAclList(&aclList);
+    delete valueFormat;
 }
 
 Note::Value::Value(const char *aVal, const bool quoted, const char *descr, const Method m)
@@ -35,7 +36,12 @@ Note::Value::Value(const char *aVal, const bool quoted, const char *descr, const
 {
     if (quoted) {
         valueFormat = new Format::Format(descr ? descr : "Notes");
-        valueFormat->parse(theValue.c_str());
+        if (!valueFormat->parse(theValue.c_str())) {
+            delete valueFormat;
+            SBuf exceptionMsg;
+            exceptionMsg.Printf("failed to parse annotation value %s", theValue.c_str());
+            throw TexcHere(exceptionMsg.c_str());
+        }
     }
 }