[OE-core] [oe-core][PATCH 1/1] gnome-desktop: do not free() a static buffer

Burton, Ross ross.burton at intel.com
Thu Mar 8 10:10:27 UTC 2018


I'm not sure we need this patch anymore, it's been rebased on top of
upstream changes but one of those changes were to fix x32 builds:

https://git.gnome.org/browse/gnome-desktop/commit/libgnome-desktop/gnome-desktop-thumbnail.c?id=012cad653253ae5f5248988cda89159f22c1fb1d

I believe we can drop this patch to gnome-desktop.

Ross

On 8 March 2018 at 01:35, Joe Slater <joe.slater at windriver.com> wrote:

> Do not free() the buffer returned by localtime().  Also,
> switch to calling localtime_r() which is re-entrant.
>
> Signed-off-by: Joe Slater <joe.slater at windriver.com>
> ---
>  ...op-thumbnail-don-t-convert-time_t-to-long.patch | 27
> +++++++++-------------
>  1 file changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-
> desktop-thumbnail-don-t-convert-time_t-to-long.patch
> b/meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-
> desktop-thumbnail-don-t-convert-time_t-to-long.patch
> index c1a7d4f..be657a8 100644
> --- a/meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-
> desktop-thumbnail-don-t-convert-time_t-to-long.patch
> +++ b/meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-
> desktop-thumbnail-don-t-convert-time_t-to-long.patch
> @@ -9,12 +9,11 @@ build for X32, where long's size doesn't match that of
> time_t.
>  Upstream-Status: Pending
>  Signed-off-by: Christopher Larson <chris_larson at mentor.com>
>
> ----
> - libgnome-desktop/gnome-desktop-thumbnail.c | 16 ++++++++++++++--
> - 1 file changed, 14 insertions(+), 2 deletions(-)
> +Modified to use localtime_r() and not free() a static structure.
> +
> +Signed-off-by: Joe Slater <jslater at windriver.com>
> +
>
> -diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c
> b/libgnome-desktop/gnome-desktop-thumbnail.c
> -index e56c3d7..5d96bf3 100644
>  --- a/libgnome-desktop/gnome-desktop-thumbnail.c
>  +++ b/libgnome-desktop/gnome-desktop-thumbnail.c
>  @@ -120,6 +120,8 @@
> @@ -30,24 +29,23 @@ index e56c3d7..5d96bf3 100644
>     char *tmp_path = NULL;
>     int tmp_fd;
>     char mtime_str[21];
> -+  struct tm *tmp_mtime = NULL;
> ++  struct tm tmp_mtime;
>     gboolean ret = FALSE;
>     GError *error = NULL;
>     const char *width, *height;
> -@@ -1124,7 +1127,11 @@ save_thumbnail (GdkPixbuf  *pixbuf,
> +@@ -1124,7 +1127,10 @@ save_thumbnail (GdkPixbuf  *pixbuf,
>       goto out;
>     close (tmp_fd);
>
>  -  g_snprintf (mtime_str, 21, "%" G_GINT64_FORMAT, (gint64) mtime);
> -+  tmp_mtime = localtime (&mtime);
> -+  if (!tmp_mtime)
> ++  if (!localtime_r (&mtime,&tmp_mtime))
>  +    goto out;
> -+  strftime (mtime_str, 21, "%s", tmp_mtime);
> -+  free (tmp_mtime);
> ++
> ++  strftime (mtime_str, 21, "%s", &tmp_mtime);
>     width = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width");
>     height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height");
>
> -@@ -1319,6 +1326,7 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf
>   *pixbuf,
> +@@ -1319,6 +1325,7 @@ gnome_desktop_thumbnail_is_valid (GdkPix
>   {
>     const char *thumb_uri, *thumb_mtime_str;
>     time_t thumb_mtime;
> @@ -55,7 +53,7 @@ index e56c3d7..5d96bf3 100644
>
>     thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI");
>     if (g_strcmp0 (uri, thumb_uri) != 0)
> -@@ -1327,7 +1335,11 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf
>     *pixbuf,
> +@@ -1327,7 +1334,11 @@ gnome_desktop_thumbnail_is_valid (GdkPix
>     thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime");
>     if (!thumb_mtime_str)
>       return FALSE;
> @@ -68,6 +66,3 @@ index e56c3d7..5d96bf3 100644
>     if (mtime != thumb_mtime)
>       return FALSE;
>
> ---
> -2.14.1
> -
> --
> 2.7.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20180308/8b547e69/attachment-0002.html>


More information about the Openembedded-core mailing list