mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
miniobject: Always reject WRITE locks on READONLY miniobjects
Verify that mapping a read-only memory as read doesnt make it writable
This commit is contained in:
parent
f02ba3b572
commit
fd846a7c64
2 changed files with 11 additions and 2 deletions
|
@ -121,8 +121,7 @@ gst_mini_object_init (GstMiniObject * mini_object, guint flags, GType type,
|
|||
{
|
||||
mini_object->type = type;
|
||||
mini_object->refcount = 1;
|
||||
mini_object->lockstate =
|
||||
(flags & GST_MINI_OBJECT_FLAG_LOCK_READONLY ? GST_LOCK_FLAG_READ : 0);
|
||||
mini_object->lockstate = 0;
|
||||
mini_object->flags = flags;
|
||||
|
||||
mini_object->copy = copy_func;
|
||||
|
@ -179,6 +178,10 @@ gst_mini_object_lock (GstMiniObject * object, GstLockFlags flags)
|
|||
g_return_val_if_fail (object != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_MINI_OBJECT_IS_LOCKABLE (object), FALSE);
|
||||
|
||||
if (G_UNLIKELY (object->flags & GST_MINI_OBJECT_FLAG_LOCK_READONLY &&
|
||||
flags & GST_LOCK_FLAG_WRITE))
|
||||
return FALSE;
|
||||
|
||||
do {
|
||||
access_mode = flags & FLAG_MASK;
|
||||
newstate = state = g_atomic_int_get (&object->lockstate);
|
||||
|
|
|
@ -149,6 +149,12 @@ GST_START_TEST (test_writable)
|
|||
|
||||
fail_if (gst_memory_map (mem, &info, GST_MAP_WRITE));
|
||||
|
||||
/* Make sure mapping anxd unmapping it doesn't change it's locking state */
|
||||
fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
|
||||
gst_memory_unmap (mem, &info);
|
||||
|
||||
fail_if (gst_memory_map (mem, &info, GST_MAP_WRITE));
|
||||
|
||||
mem2 = gst_memory_copy (mem, 0, -1);
|
||||
fail_unless (GST_MEMORY_IS_READONLY (mem));
|
||||
fail_if (GST_MEMORY_IS_READONLY (mem2));
|
||||
|
|
Loading…
Reference in a new issue