|
|
79b470 |
From 5fe7795d5fa5061f0ba615472f9351f9d29abf48 Mon Sep 17 00:00:00 2001
|
|
|
79b470 |
Message-Id: <5fe7795d5fa5061f0ba615472f9351f9d29abf48@dist-git>
|
|
|
79b470 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
79b470 |
Date: Fri, 2 Oct 2020 13:44:44 +0200
|
|
|
79b470 |
Subject: [PATCH] check for NULL before calling g_regex_unref
|
|
|
79b470 |
MIME-Version: 1.0
|
|
|
79b470 |
Content-Type: text/plain; charset=UTF-8
|
|
|
79b470 |
Content-Transfer-Encoding: 8bit
|
|
|
79b470 |
|
|
|
79b470 |
g_regex_unref reports an error if called with a NULL argument.
|
|
|
79b470 |
|
|
|
79b470 |
We have two cases in the code where we (possibly) call it on a NULL
|
|
|
79b470 |
argument. The interesting one is in virDomainQemuMonitorEventCleanup.
|
|
|
79b470 |
|
|
|
79b470 |
Based on VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX, we unref
|
|
|
79b470 |
data->regex, which has two problems:
|
|
|
79b470 |
|
|
|
79b470 |
* On the client side, flags is -1 so the comparison is true even if no
|
|
|
79b470 |
regex was used, reproducible by:
|
|
|
79b470 |
$ virsh qemu-monitor-event --timeout 1
|
|
|
79b470 |
which results in an ugly error:
|
|
|
79b470 |
(process:1289846): GLib-CRITICAL **: 14:58:42.631: g_regex_unref: assertion 'regex != NULL' failed
|
|
|
79b470 |
* On the server side, we only create the regex if both the flag and the
|
|
|
79b470 |
string are present, so it's possible to trigger this message by:
|
|
|
79b470 |
$ virsh qemu-monitor-event --regex --timeout 1
|
|
|
79b470 |
|
|
|
79b470 |
Use a non-NULL comparison instead of the flag to decide whether we need
|
|
|
79b470 |
to unref the regex. And add a non-NULL check to the unref in the
|
|
|
79b470 |
VirtualBox test too.
|
|
|
79b470 |
|
|
|
79b470 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
79b470 |
Fixes: 71efb59a4de7c51b1bc889a316f1796ebf55738f
|
|
|
79b470 |
https://bugzilla.redhat.com/show_bug.cgi?id=1876907
|
|
|
79b470 |
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
79b470 |
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
79b470 |
(cherry picked from commit 92b252456ee6d6ffc6e39e62ce1ce6c50113e00e)
|
|
|
79b470 |
|
|
|
79b470 |
https://bugzilla.redhat.com/show_bug.cgi?id=1861176
|
|
|
79b470 |
|
|
|
79b470 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
79b470 |
Message-Id: <7d3c84f6556d0d46ada037d5e56c831babba609f.1601639064.git.jtomko@redhat.com>
|
|
|
79b470 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
79b470 |
---
|
|
|
79b470 |
src/conf/domain_event.c | 2 +-
|
|
|
79b470 |
tests/vboxsnapshotxmltest.c | 3 ++-
|
|
|
79b470 |
2 files changed, 3 insertions(+), 2 deletions(-)
|
|
|
79b470 |
|
|
|
79b470 |
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
|
|
|
79b470 |
index 33fbf10406..d3acde0236 100644
|
|
|
79b470 |
--- a/src/conf/domain_event.c
|
|
|
79b470 |
+++ b/src/conf/domain_event.c
|
|
|
79b470 |
@@ -2194,7 +2194,7 @@ virDomainQemuMonitorEventCleanup(void *opaque)
|
|
|
79b470 |
virDomainQemuMonitorEventData *data = opaque;
|
|
|
79b470 |
|
|
|
79b470 |
VIR_FREE(data->event);
|
|
|
79b470 |
- if (data->flags & VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX)
|
|
|
79b470 |
+ if (data->regex)
|
|
|
79b470 |
g_regex_unref(data->regex);
|
|
|
79b470 |
if (data->freecb)
|
|
|
79b470 |
(data->freecb)(data->opaque);
|
|
|
79b470 |
diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c
|
|
|
79b470 |
index d1a7522931..8577157020 100644
|
|
|
79b470 |
--- a/tests/vboxsnapshotxmltest.c
|
|
|
79b470 |
+++ b/tests/vboxsnapshotxmltest.c
|
|
|
79b470 |
@@ -134,7 +134,8 @@ mymain(void)
|
|
|
79b470 |
DO_TEST("2disks-3snap-brother");
|
|
|
79b470 |
|
|
|
79b470 |
cleanup:
|
|
|
79b470 |
- g_regex_unref(testSnapshotXMLVariableLineRegex);
|
|
|
79b470 |
+ if (testSnapshotXMLVariableLineRegex)
|
|
|
79b470 |
+ g_regex_unref(testSnapshotXMLVariableLineRegex);
|
|
|
79b470 |
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
79b470 |
}
|
|
|
79b470 |
|
|
|
79b470 |
--
|
|
|
79b470 |
2.28.0
|
|
|
79b470 |
|