Commit eecd25e7 authored by Thomas Vander Stichele's avatar Thomas Vander Stichele
Browse files

gst/: GLib 2.6 g_flags_get_first_value has a bug that triggers an infinite loop

Original commit message from CVS:

* gst/glib-compat.c: (gst_flags_get_first_value):
* gst/glib-compat.h:
* gst/gstvalue.c: (gst_value_deserialize_int_helper),
(gst_value_compare_double), (gst_value_serialize_flags):
GLib 2.6 g_flags_get_first_value has a bug that triggers an
infinite loop
parent d4ea9fbe
2005-10-13 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/glib-compat.c: (gst_flags_get_first_value):
* gst/glib-compat.h:
* gst/gstvalue.c: (gst_value_deserialize_int_helper),
(gst_value_compare_double), (gst_value_serialize_flags):
GLib 2.6 g_flags_get_first_value has a bug that triggers an
infinite loop
2005-10-13 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/base/gstbasesink.c: (gst_base_sink_handle_object):
......
......@@ -264,3 +264,32 @@ g_stat (const gchar * filename, struct stat *buf)
#endif
}
#endif
/* This version is copied from GLib 2.8.
* In GLib 2.6, it didn't check for a flag value being NULL, hence it
* hits an infinite loop in our flags serialize function
*/
GFlagsValue *
gst_flags_get_first_value (GFlagsClass * flags_class, guint value)
{
g_return_val_if_fail (G_IS_FLAGS_CLASS (flags_class), NULL);
if (flags_class->n_values) {
GFlagsValue *flags_value;
if (value == 0) {
for (flags_value = flags_class->values; flags_value->value_name;
flags_value++)
if (flags_value->value == 0)
return flags_value;
} else {
for (flags_value = flags_class->values; flags_value->value_name;
flags_value++)
if (flags_value->value != 0
&& (flags_value->value & value) == flags_value->value)
return flags_value;
}
}
return NULL;
}
......@@ -5,6 +5,7 @@
* Copyright 2005 David Schleef <ds@schleef.org>
*/
#include <gst_private.h> /* for g_warning */
#include <glib.h>
#if GLIB_CHECK_VERSION (2, 6, 0)
#include <glib/gstdio.h>
......@@ -26,5 +27,9 @@ struct stat;
int g_stat (const gchar *filename, struct stat *buf);
#endif
#include <glib-object.h>
GFlagsValue*
gst_flags_get_first_value (GFlagsClass *flags_class,
guint value);
G_END_DECLS
......@@ -32,6 +32,7 @@
#include <ctype.h>
#include "gst_private.h"
#include "glib-compat.h"
#include <gst/gst.h>
#include <gobject/gvaluecollector.h>
......@@ -1570,7 +1571,7 @@ gst_value_serialize_flags (const GValue * value)
result = g_strdup ("");
flags = g_value_get_flags (value);
while (flags) {
fl = g_flags_get_first_value (klass, flags);
fl = gst_flags_get_first_value (klass, flags);
if (fl != NULL) {
tmp = g_strconcat (result, (first ? "" : "+"), fl->value_name, NULL);
g_free (result);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment