From b2e09396ed3be0bd3dd68e02d92e5edbc7c36d25 Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Tue, 18 May 1999 20:21:57 +0000 Subject: [PATCH] See ChangeLog entry 19990518-15:20 EDT David G. Holm --- harbour/ChangeLog | 4 ++++ harbour/source/rtl/set.c | 35 ++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 60bf374147..3126489937 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,7 @@ +19990518-15:20 EDT David G. Holm + * source/rtl/set.c + - Fixed memory leak in HB_SETCENTURY + 19990518-03:05 Ryszard Glab * source/compiler/harbour.l diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index 3b0fbdde86..a265eef48a 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -99,13 +99,16 @@ HARBOUR HB_SETCENTURY (void) else size += 2; /* Create the new date format */ szNewFormat = (char*)_xgrab (size + 1); - if (y_start > 0) memcpy (szNewFormat, szDateFormat, y_start); - szNewFormat [y_start] = 0; - strcat (szNewFormat, "YY"); - if (hb_set_century) strcat (szNewFormat, "YY"); - strcat (szNewFormat, szDateFormat + y_stop); - _xfree (szDateFormat); - hb_set.HB_SET_DATEFORMAT = szNewFormat; + if (szNewFormat) + { + if (y_start > 0) memcpy (szNewFormat, szDateFormat, y_start); + szNewFormat [y_start] = 0; + strcat (szNewFormat, "YY"); + if (hb_set_century) strcat (szNewFormat, "YY"); + if (y_stop < strlen (szDateFormat)) strcat (szNewFormat, szDateFormat + y_stop); + _xfree (szDateFormat); + hb_set.HB_SET_DATEFORMAT = szNewFormat; + } } } @@ -339,10 +342,16 @@ void InitializeSets (void) void ReleaseSets (void) { - _xfree (hb_set.HB_SET_COLOR); - _xfree (hb_set.HB_SET_DATEFORMAT); - _xfree (hb_set.HB_SET_DEFAULT); - _xfree (hb_set.HB_SET_DELIMCHARS); - _xfree (hb_set.HB_SET_DEVICE); - _xfree (hb_set.HB_SET_PATH); + if (hb_set.HB_SET_COLOR) + _xfree (hb_set.HB_SET_COLOR); + if (hb_set.HB_SET_DATEFORMAT) + _xfree (hb_set.HB_SET_DATEFORMAT); + if (hb_set.HB_SET_DEFAULT) + _xfree (hb_set.HB_SET_DEFAULT); + if (hb_set.HB_SET_DELIMCHARS) + _xfree (hb_set.HB_SET_DELIMCHARS); + if (hb_set.HB_SET_DEVICE) + _xfree (hb_set.HB_SET_DEVICE); + if (hb_set.HB_SET_PATH) + _xfree (hb_set.HB_SET_PATH); }