]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_domain: Don't unref NULL hash table in qemuDomainRefreshStatsSchema()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 26 Jan 2023 10:56:10 +0000 (11:56 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 26 Jan 2023 12:48:16 +0000 (13:48 +0100)
The g_hash_table_unref() function does not accept NULL. Passing
NULL results in a glib warning being triggered. Check whether the
hash table is not NULL and unref it only then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c

index b6ad118f1f24ef71ab3a98b09fbe0fc6b2865462..881c88d54c5ffb6b11b379e4ab0c6e6590dc3c25 100644 (file)
@@ -11923,7 +11923,8 @@ qemuDomainRefreshStatsSchema(virDomainObj *dom)
     if (!schema)
         return -1;
 
-    g_hash_table_unref(priv->statsSchema);
+    if (priv->statsSchema)
+        g_hash_table_unref(priv->statsSchema);
     priv->statsSchema = schema;
 
     return 0;