diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index bda78b2e36..3b842178ec 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -80,20 +80,23 @@ static void hb_setFreeSetPath( void ) /* Free all set paths */ HB_PATHNAMES * curPath = sp_set_path; HB_PATHNAMES * nextPath; - while( curPath ) - { - nextPath = curPath->pNext; - hb_xfree( curPath ); - curPath = nextPath; - } + if( sp_set_path ) { /* Only the first path holds an allocated string. All of the other paths in the list are part of that first string. */ hb_xfree( sp_set_path->szPath ); - sp_set_path = NULL; } + + while( curPath ) + { + nextPath = curPath->pNext; + hb_xfree( curPath ); + curPath = nextPath; + } + + sp_set_path = NULL; } static BOOL set_logical( PHB_ITEM pItem )