You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Samisa Abeysinghe <sa...@yahoo.com> on 2004/04/14 05:35:17 UTC

AxisConfig Memory leaks - patch

diff -u ../../original/ws-axis/c/src/common/AxisConfig.cpp src/common/AxisConfig.cpp
--- ../../original/ws-axis/c/src/common/AxisConfig.cpp  2004-04-07 18:59:25.000000000 +0600
+++ src/common/AxisConfig.cpp   2004-04-14 09:29:29.000000000 +0600
@@ -38,13 +38,16 @@
 AxisConfig::~AxisConfig ()
 {
     if (m_sWsddFilePath)
-        delete m_sWsddFilePath;
+        //delete m_sWsddFilePath;
+        free(m_sWsddFilePath);
     if (m_sAxisLogPath)
-        delete m_sAxisLogPath;
+        //delete m_sAxisLogPath;
+        free(m_sAxisLogPath);
     if (m_sClientWsddFilePath)
         delete m_sClientWsddFilePath;
     if (m_sAxisHome)
-        delete m_sAxisHome;
+        //delete m_sAxisHome;
+        free(m_sAxisHome);
     if (m_sValue)
         delete m_sValue;
 }
@@ -100,8 +103,11 @@
                 linesize - strlen (key) - 2);
             m_sClientWsddFilePath[linesize - strlen (key) - 2] = '\0';
         }
+        free(key);
     }

+    fclose(fileConfig);
+

     return AXIS_SUCCESS;
 }



	
		
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

Re: AxisConfig Memory leaks - patch

Posted by Samisa Abeysinghe <sa...@yahoo.com>.
Hi All,
    If I am to detail a bit about this patch...
    One C++ best practice is to match malloc() with free() and new with delete. Please do not mix
malloc() and delete.
    In AxisConfig.cpp, the opened file is never closed. Also the variable 'key' is malloc()ed but
never freed. The patch fix those problems.

Thanks,
Samisa...

--- Samisa Abeysinghe <sa...@yahoo.com> wrote:
> diff -u ../../original/ws-axis/c/src/common/AxisConfig.cpp src/common/AxisConfig.cpp
> --- ../../original/ws-axis/c/src/common/AxisConfig.cpp  2004-04-07 18:59:25.000000000 +0600
> +++ src/common/AxisConfig.cpp   2004-04-14 09:29:29.000000000 +0600
> @@ -38,13 +38,16 @@
>  AxisConfig::~AxisConfig ()
>  {
>      if (m_sWsddFilePath)
> -        delete m_sWsddFilePath;
> +        //delete m_sWsddFilePath;
> +        free(m_sWsddFilePath);
>      if (m_sAxisLogPath)
> -        delete m_sAxisLogPath;
> +        //delete m_sAxisLogPath;
> +        free(m_sAxisLogPath);
>      if (m_sClientWsddFilePath)
>          delete m_sClientWsddFilePath;
>      if (m_sAxisHome)
> -        delete m_sAxisHome;
> +        //delete m_sAxisHome;
> +        free(m_sAxisHome);
>      if (m_sValue)
>          delete m_sValue;
>  }
> @@ -100,8 +103,11 @@
>                  linesize - strlen (key) - 2);
>              m_sClientWsddFilePath[linesize - strlen (key) - 2] = '\0';
>          }
> +        free(key);
>      }
> 
> +    fclose(fileConfig);
> +
> 
>      return AXIS_SUCCESS;
>  }
> 
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> http://taxes.yahoo.com/filing.html



	
		
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html