Bug#420759: [Pkg-xfce-devel] Bug#420759: orageclock plugin leaks memory

Simon Huggins huggie at earth.li
Thu Apr 26 14:46:19 UTC 2007


fixed 420759 4.4.1-1
tags 420759 patch
thanks

On Tue, Apr 24, 2007 at 09:27:41AM -0500, Jason Kraftcheck wrote:
> orageclock panel plugin in Debian stable leaks memory every time 
> it updates the time.

> --- orage-4.3.99.1/panel-plugin/orageclock.c	2006-09-02 10:55:11.000000000 -0500
> +++ orage-mod/panel-plugin/orageclock.c	2007-04-18 15:59:20.000000000 -0500
> @@ -96,9 +96,9 @@
>      for (i = 0; i < OC_MAX_LINES; i++) {
>          line = &clock->line[i];
>          if (line->show) {
> -            strftime(time_s, sizeof(time_s)
> -                    , g_locale_from_utf8(line->data->str, -1, NULL, NULL, NULL)
> -                    , &clock->now);
> +            gchar* locstr = g_locale_from_utf8(line->data->str, -1, NULL, NULL, NULL);
> +            strftime(time_s, sizeof(time_s), locstr, &clock->now); 
> +            g_free(locstr);
>              if (!g_utf8_validate(time_s, -1, NULL)) {
>                  utf8time_s = g_locale_to_utf8(time_s, -1, NULL, NULL, NULL);
>                  if (utf8time_s) {

Upstream fixed this back in October in SVN.  We'll have to prepare a
version for proposed-updates I guess.

There is another use of g_locale_from_utf8 in a similarly bogus way just
before.

I've added this one in and used char *s as that's what future versions
of orage have used.

I end up with:
--- orage-4.3.99.1/panel-plugin/orageclock.c	2006-09-02 16:55:11.000000000 +0100
+++ orage-4.3.99.1-mod/panel-plugin/orageclock.c	2007-04-26 15:30:13.000000000 +0100
@@ -49,6 +49,7 @@
 {
     char date_s[255];
     char *utf8date = NULL;
+    char *tmp;
 
     /* TRANSLATORS: Use format characters from strftime(3)
      * to get the proper string for your locale.
@@ -59,9 +60,11 @@
      * %Y  : four digit year
      * %V  : ISO week number
      */
+    tmp = g_locale_from_utf8( _("%A %d %B %Y/%V"), -1, NULL, NULL, NULL);
     strftime(date_s, 255
-            , g_locale_from_utf8( _("%A %d %B %Y/%V"), -1, NULL, NULL, NULL)
+            , tmp
             , &clock->now);
+    g_free(tmp);
 
     /* Conversion to utf8 */
     if (!g_utf8_validate(date_s, -1, NULL)) {
@@ -89,6 +92,7 @@
     int     i;
     static gint mday = -1;
     ClockLine *line;
+    char *tmp;
 
     time(&t);
     localtime_r(&t, &clock->now);
@@ -96,9 +100,11 @@
     for (i = 0; i < OC_MAX_LINES; i++) {
         line = &clock->line[i];
         if (line->show) {
+            tmp = g_locale_from_utf8(line->data->str, -1, NULL, NULL, NULL);
             strftime(time_s, sizeof(time_s)
-                    , g_locale_from_utf8(line->data->str, -1, NULL, NULL, NULL)
+                    , tmp
                     , &clock->now);
+            g_free(tmp);
             if (!g_utf8_validate(time_s, -1, NULL)) {
                 utf8time_s = g_locale_to_utf8(time_s, -1, NULL, NULL, NULL);
                 if (utf8time_s) {


Does that look sane to you?

It builds at least.  I need to create a stable chroot and a stable
pbuilder environment to properly test it yet but if you could test it as
well that would help.

Simon

-- 
... "I know what I wrote Mulder. I also know that the laws of physics would
    permit the theoretical possibility of time travel but the limits of
    human endurance would prevent such a trip from ever happening"




More information about the Pkg-xfce-devel mailing list