[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] possible memory leak in tclock


i have maybe found an memory leak in tclock(and maybe also in other

in the _fill_data function (e_mod_config.c:41ff) the strings for the
time and date format(from the Config_Item struct) are duplicated via the
strdup function.

in _basic_apply_data (e_mod_config.c:120ff)
the string pointers for the date and time format strings(of the
Config_Item struct) gets "overwritten" with the values of the
E_Config_Dialog_Data-struct. The date and time format-string pointers
of the  E_Config_Dialog_Data-struct have the adresses of the nes strings
which was created via the strdup function in _fill_data.

Due this assignment in _basic_apply_data the old addresses get lost and
the memory areas doesn't get freed.

So shouldn't be freed the old strings before the strings from
E_Config_Dialog_Data struct get saved in the Config_item struct.

i have attached a small patch wich resolves this problem(if it is a
problem which i think it is a problem).

Ein Ring, sie zu knechten, sie alle zu finden,
Ins Dunkel zu treiben und ewig zu binden
Im Lande Mordor, wo die Schatten drohn.
? tclock.patch
Index: e_mod_config.c
RCS file: /var/cvs/e/e_modules/tclock/e_mod_config.c,v
retrieving revision 1.21
diff -u -r1.21 e_mod_config.c
--- e_mod_config.c	22 May 2006 02:10:35 -0000	1.21
+++ e_mod_config.c	22 Jun 2006 16:33:26 -0000
@@ -124,7 +124,9 @@
    ci = cfd->data;
    ci->show_date = cfdata->show_date;
    ci->show_time = cfdata->show_time;
+   if(ci->time_format) free(ci->time_format);
    ci->time_format = cfdata->time_format;
+   if(ci->date_format) free(ci->date_format);
    ci->date_format = cfdata->date_format;
    ci->resolution = cfdata->resolution;