[gnome-software] snap: Don't pass NULL to g_date_time_to_unix



commit e766ac5bd36295a851bf08296734f7df45208dd9
Author: Andrea Azzarone <azzaronea gmail com>
Date:   Mon Jul 16 21:44:45 2018 +0200

    snap: Don't pass NULL to g_date_time_to_unix
    
    As per API documentation, snapd_snap_get_install_date can return NULL. Passing
    NULL to g_date_time_to_unix results in a crash. When this happens we should pass
    GS_APP_INSTALL_DATE_UNKNOWN to gs_app_set_install_date.
    
    Fixes: https://bugs.launchpad.net/bugs/1781996

 plugins/snap/gs-plugin-snap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 14571efe..6323f6ca 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -823,9 +823,11 @@ gs_plugin_refine_app (GsPlugin *plugin,
        /* add information specific to installed snaps */
        if (local_snap != NULL) {
                SnapdApp *snap_app;
+               GDateTime *install_date;
 
+               install_date = snapd_snap_get_install_date (local_snap);
                gs_app_set_size_installed (app, snapd_snap_get_installed_size (local_snap));
-               gs_app_set_install_date (app, g_date_time_to_unix (snapd_snap_get_install_date (local_snap)));
+               gs_app_set_install_date (app, install_date != NULL ? g_date_time_to_unix (install_date) : 
GS_APP_INSTALL_DATE_UNKNOWN);
 
                snap_app = get_primary_app (local_snap);
                if (snap_app != NULL) {


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