gst/gstindex.*: Don't free key strings which we don't own. Fixes crash in gst_index_entry_free() (#522741).

Original commit message from CVS:
* gst/gstindex.c: (gst_index_entry_free):
* gst/gstindex.h:
Don't free key strings which we don't own. Fixes crash in
gst_index_entry_free() (#522741).
* tests/check/Makefile.am:
* tests/check/gst/.cvsignore:
* tests/check/gst/gstindex.c: (test_index_entries),
(gst_index_suite), (gst_index):
Add unit test for the above.
This commit is contained in:
Tim-Philipp Müller 2008-03-17 10:21:59 +00:00
parent 567f929b8c
commit ede8ee12bb
6 changed files with 75 additions and 9 deletions

View file

@ -1,3 +1,16 @@
2008-03-17 Tim-Philipp Müller <tim at centricular dot net>
* gst/gstindex.c: (gst_index_entry_free):
* gst/gstindex.h:
Don't free key strings which we don't own. Fixes crash in
gst_index_entry_free() (#522741).
* tests/check/Makefile.am:
* tests/check/gst/.cvsignore:
* tests/check/gst/gstindex.c: (test_index_entries),
(gst_index_suite), (gst_index):
Add unit test for the above.
2008-03-11 Sebastian Dröge <slomo@circular-chaos.org>
* win32/common/libgstreamer.def:

View file

@ -545,16 +545,8 @@ gst_index_entry_free (GstIndexEntry * entry)
}
break;
case GST_INDEX_ENTRY_OBJECT:
if (entry->data.object.key) {
g_free (entry->data.object.key);
entry->data.object.key = NULL;
}
break;
case GST_INDEX_ENTRY_FORMAT:
if (entry->data.format.key) {
g_free (entry->data.format.key);
entry->data.format.key = NULL;
}
break;
}

View file

@ -214,7 +214,7 @@ struct _GstIndexEntry {
} object;
struct {
GstFormat format;
gchar *key;
const gchar *key;
} format;
} data;
};

View file

@ -49,6 +49,7 @@ REGISTRY_CHECKS = \
gst/gstelement \
gst/gstevent \
gst/gstghostpad \
gst/gstindex \
gst/gstinterface \
gst/gstplugin \
gst/gstquery \

View file

@ -10,6 +10,7 @@ gstelement
gstevent
gstghostpad
gstiterator
gstindex
gstinterface
gstmessage
gstminiobject

View file

@ -0,0 +1,59 @@
/* GStreamer GstIndex unit test
* Copyright (C) 2008 Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gst/check/gstcheck.h>
#include <gst/gst.h>
#include <string.h>
GST_START_TEST (test_index_entries)
{
GstIndexEntry *entry;
GstElement *pipe;
GstIndex *index;
gint id = -1;
pipe = gst_pipeline_new ("pipeline");
index = gst_index_new ();
fail_unless (gst_index_get_writer_id (index, GST_OBJECT (pipe), &id));
entry = gst_index_add_format (index, id, GST_FORMAT_BYTES);
gst_index_entry_free (entry);
gst_object_unref (index);
gst_object_unref (pipe);
}
GST_END_TEST;
static Suite *
gst_index_suite (void)
{
Suite *s = suite_create ("GstIndex");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_index_entries);
return s;
}
GST_CHECK_MAIN (gst_index);