From: petgit Date: Wed, 27 Aug 2014 19:52:53 +0000 (+0200) Subject: use of g_free() cause heap damage on windows if memory is allocated by malloc().... X-Git-Tag: v1.5.0-rc1~46^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F529%2Fhead;p=thirdparty%2Frrdtool-1.x.git use of g_free() cause heap damage on windows if memory is allocated by malloc(). Key is allocated by malloc() in sprintf_alloc(), so free() should use. --- diff --git a/src/rrd_graph.c b/src/rrd_graph.c index b99d0bee..1d651855 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -343,11 +343,7 @@ int im_free( } if (im->rrd_map){ - //TODO: - // check reason of error: - // Unhandled exception at 0x77BBF636 (ntdll.dll) in rrdtool.exe: 0xC0000374: a Heap was damaged (parameters: 0x77BDD338). - // at following line - //g_hash_table_destroy(im->rrd_map); + g_hash_table_destroy(im->rrd_map); } @@ -4307,7 +4303,8 @@ void rrd_graph_init( tzset(); #endif im->gdef_map = g_hash_table_new_full(g_str_hash, g_str_equal,g_free,NULL); - im->rrd_map = g_hash_table_new_full(g_str_hash, g_str_equal,g_free,NULL); + //use of g_free() cause heap damage on windows. Key is allocated by malloc() in sprintf_alloc(), so free() must use + im->rrd_map = g_hash_table_new_full(g_str_hash, g_str_equal,free,NULL); im->graph_type = GTYPE_TIME; im->base = 1000; im->daemon_addr = NULL; diff --git a/win32/librrd-4.vcxproj b/win32/librrd-4.vcxproj index 9fc0551e..aebcd39a 100644 --- a/win32/librrd-4.vcxproj +++ b/win32/librrd-4.vcxproj @@ -106,7 +106,7 @@ EnableFastChecks MultiThreadedDebugDLL - + precompiled.h $(IntDir)librrd-4.pdb Level3 ProgramDatabase @@ -131,7 +131,7 @@ precompiled.h $(IntDir)librrd-4.pdb Level3 - ProgramDatabase + None CompileAsCpp 4996;%(DisableSpecificWarnings) @@ -149,7 +149,7 @@ EnableFastChecks MultiThreadedDebug - + precompiled.h $(IntDir)librrd-4.pdb Level3 ProgramDatabase @@ -172,11 +172,12 @@ EnableFastChecks MultiThreadedDebug - + precompiled.h Level3 ProgramDatabase CompileAsCpp 4996;%(DisableSpecificWarnings) + $(IntDir)librrd-4.pdb cairo.lib;pango-1.0.lib;pangocairo-1.0.lib;libpng.lib;zdll.lib;glib-2.0.lib;gobject-2.0.lib;libxml2.lib;%(AdditionalDependencies) @@ -194,7 +195,7 @@ EnableFastChecks MultiThreaded - + precompiled.h $(IntDir)librrd-4.pdb TurnOffAllWarnings ProgramDatabase