From b2099ee728addd34b0497bcddcc0fcd6a2503f0b Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 20 Oct 2011 21:35:59 +0000 Subject: * fhandler.h (fhandler*::copyto): Free path_conv strings first. * path.h (cfree_and_null): Rename and expand from cfree_maybe. (path_conv &operator =): Call free_strings rather than freeing strings directly. --- winsup/cygwin/path.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'winsup/cygwin/path.h') diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 3a9c08ca4..f390156cc 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -282,12 +282,21 @@ class path_conv PWCHAR get_wide_win32_path (PWCHAR wc); operator DWORD &() {return fileattr;} operator int () {return fileattr; } -# define cfree_maybe(x) if (x) cfree ((void *) (x)) +# define cfree_and_null(x) \ + if (x) \ + { \ + cfree ((void *) (x)); \ + (x) = NULL; \ + } + void free_strings () + { + cfree_and_null (path); + cfree_and_null (normalized_path); + cfree_and_null (wide_path); + } path_conv &operator =(const path_conv& pc) { - cfree_maybe (path); - cfree_maybe (normalized_path); - cfree_maybe (wide_path); + free_strings (); memcpy (this, &pc, sizeof pc); path = cstrdup (pc.path); conv_handle.dup (pc.conv_handle); -- cgit v1.2.3