On Thu, Feb 18, 2010 at 12:08:37AM +0800, John McCabe-Dansted wrote:
> On Sun, Feb 14, 2010 at 11:27 PM, John McCabe-Dansted <gma...@gmail.com> 
> wrote:
> > http://gmatht.homelinux.net/xp/lyx/cppcheck/
> 
> Attached is a possible fix for:
> 
> [./src/support/os_cygwin.cpp:181]: (error) Mismatching allocation and
> deallocation: ptr
> 
> Does it look right?

Yes, everytime you use new[], you should also use delete[], even when
allocating POD types. The default behaviour of delete[] is calling
delete anyway, so it normally makes no difference in the POD case.
However, if new[] and delete[] are redefined, a runtime disaster could
occur. Thanks for spotting it.

> 
> 
> -- 
> John C. McCabe-Dansted

> Index: lyx/src/support/os_cygwin.cpp
> ===================================================================
> --- lyx/src/support/os_cygwin.cpp     (revision 33487)
> +++ lyx/src/support/os_cygwin.cpp     (working copy)
> @@ -178,7 +178,7 @@
>                               cygwin_posix_to_win32_path_list(pc, ptr);
>  
>                       string path_list = subst(ptr, '\\', '/');
> -                     delete ptr;
> +                     delete [] ptr;
>                       return path_list;
>               }
>       }


-- 
Enrico

Reply via email to