[Spice-commits] 3 commits - gtk/channel-display.c gtk/channel-port.c gtk/glib-compat.c gtk/glib-compat.h gtk/spice-channel.c
Uri Lublin
uril at kemper.freedesktop.org
Mon Dec 10 07:59:47 PST 2012
gtk/channel-display.c | 16 ++++++++++++++--
gtk/channel-port.c | 1 +
gtk/glib-compat.c | 27 +++++++++++++++++++++++++++
gtk/glib-compat.h | 5 +++++
gtk/spice-channel.c | 1 +
5 files changed, 48 insertions(+), 2 deletions(-)
New commits:
commit 15df2d387e31f032ef7ef903a7b6c18972b39ed1
Author: Uri Lublin <uril at redhat.com>
Date: Wed Dec 5 16:33:01 2012 +0200
gtk/channel-port: include glib-compat for g_clear_pointer
diff --git a/gtk/channel-port.c b/gtk/channel-port.c
index e1f61d2..1d6eef2 100644
--- a/gtk/channel-port.c
+++ b/gtk/channel-port.c
@@ -19,6 +19,7 @@
#include "spice-common.h"
#include "spice-channel-priv.h"
#include "spice-marshal.h"
+#include "glib-compat.h"
/**
* SECTION:channel-port
commit 16b5ca3655e1ecd3dcf118e612011f176fe5003a
Author: Uri Lublin <uril at redhat.com>
Date: Wed Dec 5 16:17:20 2012 +0200
glib-compat: add g_slist_free_full
diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
index 7bb906c..5f2e29e 100644
--- a/gtk/glib-compat.c
+++ b/gtk/glib-compat.c
@@ -41,6 +41,33 @@ g_simple_async_result_take_error (GSimpleAsyncResult *simple,
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
+
+
+/**
+ * g_slist_free_full: (skip)
+ * @list: a #GSList
+ * @free_func: a #GDestroyNotify
+ *
+ * Convenience method, which frees all the memory used by a #GSList,
+ * and calls the specified destroy function on every element's data
+ *
+ * Since: 2.28
+ **/
+G_GNUC_INTERNAL void
+g_slist_free_full(GSList *list,
+ GDestroyNotify free_func)
+{
+ GSList *el;
+
+ if (free_func) {
+ for (el = list; el ; el = g_slist_next(el)) {
+ free_func(el);
+ }
+ }
+
+ g_slist_free(list);
+}
+
#endif
#if !GLIB_CHECK_VERSION(2,30,0)
diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
index 909b4e1..64e7eb1 100644
--- a/gtk/glib-compat.h
+++ b/gtk/glib-compat.h
@@ -88,6 +88,11 @@ GType spice_error_get_type (void) G_GNUC_CONST;
void
g_simple_async_result_take_error(GSimpleAsyncResult *simple,
GError *error);
+
+void
+g_slist_free_full(GSList *list,
+ GDestroyNotify free_func);
+
#endif /* glib 2.28 */
#if !GLIB_CHECK_VERSION(2,30,0)
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 36fe21e..264d1f2 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -17,6 +17,7 @@
*/
#include "spice-client.h"
#include "spice-common.h"
+#include "glib-compat.h"
#include "spice-channel-priv.h"
#include "spice-session-priv.h"
commit 9dc94ccc6dbf8e8b7d405f10504b04a426077611
Author: Uri Lublin <uril at redhat.com>
Date: Wed Dec 5 14:59:29 2012 +0200
channel-display: add more protection against bad access to streams
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 77959b9..d07b65c 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -1239,9 +1239,14 @@ static void display_handle_stream_data(SpiceChannel *channel, SpiceMsgIn *in)
{
SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
SpiceStreamDataHeader *op = spice_msg_in_parsed(in);
- display_stream *st = c->streams[op->id];
+ display_stream *st;
guint32 mmtime;
+ g_return_if_fail(c != NULL);
+ g_return_if_fail(c->streams != NULL);
+ g_return_if_fail(c->nstreams > op->id);
+
+ st = c->streams[op->id];
mmtime = spice_session_get_mm_time(spice_channel_get_session(channel));
if (spice_msg_in_type(in) == SPICE_MSG_DISPLAY_STREAM_DATA_SIZED) {
@@ -1269,7 +1274,13 @@ static void display_handle_stream_clip(SpiceChannel *channel, SpiceMsgIn *in)
{
SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
SpiceMsgDisplayStreamClip *op = spice_msg_in_parsed(in);
- display_stream *st = c->streams[op->id];
+ display_stream *st;
+
+ g_return_if_fail(c != NULL);
+ g_return_if_fail(c->streams != NULL);
+ g_return_if_fail(c->nstreams > op->id);
+
+ st = c->streams[op->id];
if (st->msg_clip) {
spice_msg_in_unref(st->msg_clip);
@@ -1292,6 +1303,7 @@ static void destroy_stream(SpiceChannel *channel, int id)
g_return_if_fail(c != NULL);
g_return_if_fail(c->streams != NULL);
+ g_return_if_fail(c->nstreams > id);
st = c->streams[id];
if (!st)
More information about the Spice-commits
mailing list