From 03991ab0734ecbb87a75238d1356fbe0e5b1d38d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Aug 2008 13:35:15 -0700 Subject: Fix bug 5686 - libsmbclient segfaults with more than one SMBCCTX. Here is a patch to allow many subsystems to be re-initialized. The only functional change I made was to remove the null context tracking, as the memory allocated here is designed to be left for the complete lifetime of the program. Freeing this early (when all smb contexts are destroyed) could crash other users of talloc. Jeremy. (This used to be commit 8c630efd25cf17aff59448ca05c1b44a41964b16) --- source3/lib/debug.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'source3/lib/debug.c') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 2ded6bdc33..d835ea7c17 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -94,7 +94,7 @@ static TALLOC_CTX *tmp_debug_ctx; /* * This is to allow assignment to DEBUGLEVEL before the debug - * system has been initialised. + * system has been initialized. */ static int debug_all_class_hack = 1; static bool debug_all_class_isset_hack = True; @@ -183,6 +183,8 @@ static char **classname_table = NULL; Free memory pointed to by global pointers. ****************************************************************************/ +static bool initialized; + void gfree_debugsyms(void) { int i; @@ -194,13 +196,23 @@ void gfree_debugsyms(void) SAFE_FREE( classname_table ); } - if ( DEBUGLEVEL_CLASS != &debug_all_class_hack ) + if ( DEBUGLEVEL_CLASS != &debug_all_class_hack ) { SAFE_FREE( DEBUGLEVEL_CLASS ); + DEBUGLEVEL_CLASS = &debug_all_class_hack; + } - if ( DEBUGLEVEL_CLASS_ISSET != &debug_all_class_isset_hack ) + if ( DEBUGLEVEL_CLASS_ISSET != &debug_all_class_isset_hack ) { SAFE_FREE( DEBUGLEVEL_CLASS_ISSET ); + DEBUGLEVEL_CLASS_ISSET = &debug_all_class_isset_hack; + } SAFE_FREE(format_bufr); + + debug_num_classes = 0; + + debug_level = DEBUGLEVEL_CLASS; + + initialized = false; } /**************************************************************************** @@ -530,13 +542,12 @@ Init debugging (one time stuff) void debug_init(void) { - static bool initialised = False; const char **p; - if (initialised) + if (initialized) return; - initialised = True; + initialized = true; for(p = default_classname_table; *p; p++) { debug_add_class(*p); -- cgit