From: Eduard Bagdasaryan Date: Tue, 14 Feb 2017 02:03:27 +0000 (+1300) Subject: Fix memory leak and parse handling error introduced by r15024. X-Git-Tag: M-staged-PR71~273 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5db97e7aa415bd1630a7d47d59d7ea88aa0d17b;p=thirdparty%2Fsquid.git Fix memory leak and parse handling error introduced by r15024. * 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) --- diff --git a/src/Notes.cc b/src/Notes.cc index d424489b4b..c1b25bc679 100644 --- a/src/Notes.cc +++ b/src/Notes.cc @@ -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()); + } } }