[Spice-devel,spice-gtk,v1,8/9] debug: don't segfault on CHANNEL_DEBUG

Submitted by Victor Toso on May 19, 2016, 11:21 a.m.

Details

Message ID 1463656909-25267-8-git-send-email-victortoso@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 2 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso May 19, 2016, 11:21 a.m.
On a test environment, not always we have the channel present on
CHANNEL_DEBUG which could cause a crash in the code. Just defaults to
"no-channel" should be enough.
---
 src/spice-channel-priv.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/spice-channel-priv.h b/src/spice-channel-priv.h
index 526b661..f0bb017 100644
--- a/src/spice-channel-priv.h
+++ b/src/spice-channel-priv.h
@@ -41,7 +41,9 @@  G_BEGIN_DECLS
 #define MAX_SPICE_DATA_HEADER_SIZE sizeof(SpiceDataHeader)
 
 #define CHANNEL_DEBUG(channel, fmt, ...) \
-    SPICE_DEBUG("%s: " fmt, SPICE_CHANNEL(channel)->priv->name, ## __VA_ARGS__)
+    SPICE_DEBUG("%s: " fmt, \
+            (channel) ? SPICE_CHANNEL(channel)->priv->name : "no-channel", \
+            ## __VA_ARGS__)
 
 struct _SpiceMsgOut {
     int                   refcount;