axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samisa Abeysinghe <samisa_abeysin...@yahoo.com>
Subject Re: AxisConfig Memory leaks - patch
Date Wed, 14 Apr 2004 04:22:07 GMT
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 <samisa_abeysinghe@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

Mime
View raw message