[Libosinfo] [PATCH osinfo-db-tools 4/7] export: Don't call g_object_unref(NULL) in _create_file()

Christophe Fergeau cfergeau at redhat.com
Fri Sep 21 10:00:43 UTC 2018


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Fri, Sep 21, 2018 at 11:13:45AM +0200, Fabiano Fidêncio wrote:
> In osinfo_db_create_file() g_file_query_info() may fail which will leave
> @info as a NULL and we'll try to free it in the cleanup causing:
> (osinfo-db-export:32261): GLib-GObject-CRITICAL **: 11:00:08.488: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
> 
> In order to avoid that, let's only call g_object_unref() when @info is
> not NULL.
> 
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
>  tools/osinfo-db-export.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/osinfo-db-export.c b/tools/osinfo-db-export.c
> index 2c1bb8d..820196f 100644
> --- a/tools/osinfo-db-export.c
> +++ b/tools/osinfo-db-export.c
> @@ -286,7 +286,8 @@ static int osinfo_db_export_create_file(const gchar *prefix,
>      g_free(abspath);
>      g_free(relpath);
>      g_free(entpath);
> -    g_object_unref(info);
> +    if (info)
> +        g_object_unref(info);
>      if (err)
>          g_error_free(err);
>      return ret;
> -- 
> 2.17.1
> 
> _______________________________________________
> Libosinfo mailing list
> Libosinfo at redhat.com
> https://www.redhat.com/mailman/listinfo/libosinfo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libosinfo/attachments/20180921/734cfc1b/attachment.sig>


More information about the Libosinfo mailing list