]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: fix potential memory leak in HTMLFormatter 20699/head
authorYao Zongyou <yaozongyou@vip.qq.com>
Mon, 5 Mar 2018 02:57:38 +0000 (10:57 +0800)
committerYao Zongyou <yaozongyou@vip.qq.com>
Mon, 5 Mar 2018 02:57:38 +0000 (10:57 +0800)
If HTMLFormatter::set_status called twice, memory will leaked,
so fix it.

Signed-off-by: Yao Zongyou <yaozongyou@vip.qq.com>
src/common/HTMLFormatter.cc

index 5889566d74c40775f15450fd5487f548a9ffe5cf..1ad6a6d88e567dbe0f9d49fe2baf93e24430f262 100644 (file)
@@ -57,6 +57,9 @@ void HTMLFormatter::set_status(int status, const char* status_name)
 {
   m_status = status;
   if (status_name) {
+    if (m_status_name) {
+      free((void*)m_status_name);
+    }
     m_status_name = strdup(status_name);
   }
 };