From nobody Fri Apr 26 06:19:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599571292; cv=none; d=zohomail.com; s=zohoarc; b=eNS99ApBiAfqIVTLeY6Ks+NOsiem235w04fvWa5+pVmV2ObqUaDgjznl9tYtdnSVknv9QHyax8sX+RRGw5C5798q0YpFQXMb7QoQk7JgydHrNz4bSlr8FqUYpy/X/YN9kYAdq1QxmyDckX29wPCQBxQ8TT1fF5wkHVy/RKXaBE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599571292; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=sK0/12P7lnICcFx+DTTWEN+VHCcT+NjcAVt2HnjPiUg=; b=CLH2+q83Byb5ShxHkzn3zV2LloQkUaFKhenn/ecUsAsA4uGN7UXetBhW6KlrLcf40kyFQYHR6DIgtpvJKdEueFlojUBN6IaNbdDwf8pKJc2lDj//Dj9c9mGbTgwvXC5UonNa4PbeDzw98BmvJY3Uny6sF4jWBMGZQwSfNTAy+lc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1599571292363993.650861852581; Tue, 8 Sep 2020 06:21:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144-PFN8l5Z2NnW0BoKzgG7OBw-1; Tue, 08 Sep 2020 09:21:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F003A10054FF; Tue, 8 Sep 2020 13:21:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A71F5D9E8; Tue, 8 Sep 2020 13:21:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 40DC7181A050; Tue, 8 Sep 2020 13:21:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 088DLJYc020426 for ; Tue, 8 Sep 2020 09:21:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF539100238C; Tue, 8 Sep 2020 13:21:19 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3734A1002D47 for ; Tue, 8 Sep 2020 13:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599571291; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sK0/12P7lnICcFx+DTTWEN+VHCcT+NjcAVt2HnjPiUg=; b=jRyIgx4Mq1wGa68oWqaFBjin86MFfXAHB6fZzAtUIDTnewWUJOgX5dDnZYXVAFMimaVIhe /HwmoA62XQ8FEJ5M2yqwxx7hkiKGQQAWt5vMQsv1nXARrfTUFtS4+qgWGTuB9qS9LOvcY/ hwZhZZSNbwNOFSEu1CMamvfKiZNyo1k= X-MC-Unique: PFN8l5Z2NnW0BoKzgG7OBw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH] check for NULL before calling g_regex_unref Date: Tue, 8 Sep 2020 15:20:52 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) g_regex_unref reports an error if called with a NULL argument. We have two cases in the code where we (possibly) call it on a NULL argument. The interesting one is in virDomainQemuMonitorEventCleanup. Based on VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX, we unref data->regex, which has two problems: * On the client side, flags is -1 so the comparison is true even if no regex was used, reproducible by: $ virsh qemu-monitor-event --timeout 1 which results in an ugly error: (process:1289846): GLib-CRITICAL **: 14:58:42.631: g_regex_unref: assertion= 'regex !=3D NULL' failed * On the server side, we only create the regex if both the flag and the string are present, so it's possible to trigger this message by: $ virsh qemu-monitor-event --regex --timeout 1 Use a non-NULL comparison instead of the flag to decide whether we need to unref the regex. Signed-off-by: J=C3=A1n Tomko Fixes: 71efb59a4de7c51b1bc889a316f1796ebf55738f https://bugzilla.redhat.com/show_bug.cgi?id=3D1861176 Reviewed-by: Martin Kletzander Reviewed-by: Peter Krempa --- src/conf/domain_event.c | 2 +- tests/vboxsnapshotxmltest.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index 33fbf10406..d3acde0236 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -2194,7 +2194,7 @@ virDomainQemuMonitorEventCleanup(void *opaque) virDomainQemuMonitorEventData *data =3D opaque; =20 VIR_FREE(data->event); - if (data->flags & VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX) + if (data->regex) g_regex_unref(data->regex); if (data->freecb) (data->freecb)(data->opaque); diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index 7e3f85cc58..d2beb7858d 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -135,7 +135,8 @@ mymain(void) DO_TEST("2disks-3snap-brother"); =20 cleanup: - g_regex_unref(testSnapshotXMLVariableLineRegex); + if (testSnapshotXMLVariableLineRegex) + g_regex_unref(testSnapshotXMLVariableLineRegex); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 --=20 2.26.2