Hello!
This code has memory leaks, either if theWorkspace is NULL or if the fopen fails.
#ifdef G_OS_WIN32 char *temp_file = g_strdup_printf("%s\_%d_%ld_1.cpp", config_dir, getpid(), time(NULL)); char *temp_file2 = g_strdup_printf("%s\_%d_%ld_2.cpp", config_dir, getpid(), time(NULL)); #else char *temp_file = g_strdup_printf("%s/%d_%ld_1.cpp", config_dir, getpid(), time(NULL)); char *temp_file2 = g_strdup_printf("%s/%d_%ld_2.cpp", config_dir, getpid(), time(NULL)); #endif
if (NULL == theWorkspace || NULL == (fp = g_fopen(temp_file, "w"))) return FALSE;
I changed it to:
#ifdef G_OS_WIN32 char *temp_file = g_strdup_printf("%s\_%d_%ld_1.cpp", config_dir, getpid(), time(NULL)); char *temp_file2 = g_strdup_printf("%s\_%d_%ld_2.cpp", config_dir, getpid(), time(NULL)); #else char *temp_file = g_strdup_printf("%s/%d_%ld_1.cpp", config_dir, getpid(), time(NULL)); char *temp_file2 = g_strdup_printf("%s/%d_%ld_2.cpp", config_dir, getpid(), time(NULL)); #endif
if (NULL == theWorkspace || NULL == (fp = g_fopen(temp_file, "w"))) { g_free(temp_file); g_free(temp_file2); return FALSE; }
Best regards, Daniel
<P><p><font face="Arial, Helvetica, sans-serif" size="2" style="font-size:13.5px">_______________________________________________________________<BR>Parfym och kosmetik upp till 50% billigare hos BeautyPlanet.se - <a style="font-family: Tahoma, sans-serif; font-size: 12px; color: #00f" href="http://secure-dk.imrworldwide.com/cgi-bin/b?ci=aller-kampanj-se&cg=spray&tu=http%3A%2F%2Fwww.beautyplanet.se%2F%3Futm_source%3DSpray%26utm_medium%3DMailfooter%26utm_campaign%3DGenerell" target="_blank"> Klicka här!</a></font>
On Sun, 6 Jun 2010 02:49:46 -0700, Daniel wrote:
Hello!
This code has memory leaks, either if theWorkspace is NULL or if the fopen fails.
Thanks a lot. Committed.
You are the #1 memleak hunter :). Good job!
Regards, Enrico