r19985 - gnucash/trunk/src/app-utils - Patch some memory leaks. scm_to_locale_string() returns a string which must be freed

Derek Atkins derek at ihtfp.com
Tue Dec 28 20:42:45 EST 2010


Phil,

Are you sure that scm_to_locale_string() is returning a g_alloc'ed string
and not a malloc'ed string?  You cannot mix-and-match malloc/free and
g_alloc/g_free.

-derek

On Tue, December 28, 2010 8:36 pm, Phil Longstaff wrote:
> Author: plongstaff
> Date: 2010-12-28 20:36:26 -0500 (Tue, 28 Dec 2010)
> New Revision: 19985
> Trac: http://svn.gnucash.org/trac/changeset/19985
>
> Modified:
>    gnucash/trunk/src/app-utils/guile-util.c
> Log:
> Patch some memory leaks.  scm_to_locale_string() returns a string which
> must be freed
>
>
> Modified: gnucash/trunk/src/app-utils/guile-util.c
> ===================================================================
> --- gnucash/trunk/src/app-utils/guile-util.c	2010-12-28 20:44:25 UTC (rev
> 19984)
> +++ gnucash/trunk/src/app-utils/guile-util.c	2010-12-29 01:36:26 UTC (rev
> 19985)
> @@ -162,7 +162,7 @@
>          value = scm_call_1(func, arg);
>
>          if (scm_is_string(value))
> -            return g_strdup(scm_to_locale_string(value));
> +            return scm_to_locale_string(value);
>          else
>          {
>              PERR("bad value\n");
> @@ -660,7 +660,7 @@
>      if (!scm_is_string(result))
>          return NULL;
>
> -    return g_strdup(scm_to_locale_string(result));
> +    return scm_to_locale_string(result);
>  }
>
>
> @@ -685,7 +685,7 @@
>      if (!scm_is_string(result))
>          return NULL;
>
> -    return g_strdup(scm_to_locale_string(result));
> +    return scm_to_locale_string(result);
>  }
>
>
> @@ -1115,10 +1115,7 @@
>      if (!scm_is_string(result))
>          return NULL;
>
> -    string = scm_to_locale_string(result);
> -    if (string)
> -        return g_strdup(string);
> -    return NULL;
> +    return scm_to_locale_string(result);
>  }
>
>
> @@ -1150,10 +1147,7 @@
>      if (!scm_is_string(result))
>          return NULL;
>
> -    string = scm_to_locale_string(result);
> -    if (string)
> -        return g_strdup(string);
> -    return NULL;
> +    return scm_to_locale_string(result);
>  }
>
>
>
> _______________________________________________
> gnucash-changes mailing list
> gnucash-changes at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-changes
>



More information about the gnucash-devel mailing list