mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
memory/buffer: Initialise GstMapInfo to zeroes if mapping fails
This should allow for more meaningful errors. Dereferencing NULL is more useful information than dereferencing a random address happened to be on the stack.
This commit is contained in:
parent
dded0a4bb6
commit
81f9a22228
2 changed files with 5 additions and 4 deletions
|
@ -1583,21 +1583,20 @@ not_writable:
|
|||
{
|
||||
GST_WARNING_OBJECT (buffer, "write map requested on non-writable buffer");
|
||||
g_critical ("write map requested on non-writable buffer");
|
||||
memset (info, 0, sizeof (GstMapInfo));
|
||||
return FALSE;
|
||||
}
|
||||
no_memory:
|
||||
{
|
||||
/* empty buffer, we need to return NULL */
|
||||
GST_DEBUG_OBJECT (buffer, "can't get buffer memory");
|
||||
info->memory = NULL;
|
||||
info->data = NULL;
|
||||
info->size = 0;
|
||||
info->maxsize = 0;
|
||||
memset (info, 0, sizeof (GstMapInfo));
|
||||
return TRUE;
|
||||
}
|
||||
cannot_map:
|
||||
{
|
||||
GST_DEBUG_OBJECT (buffer, "cannot map memory");
|
||||
memset (info, 0, sizeof (GstMapInfo));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,6 +310,7 @@ gst_memory_map (GstMemory * mem, GstMapInfo * info, GstMapFlags flags)
|
|||
lock_failed:
|
||||
{
|
||||
GST_CAT_DEBUG (GST_CAT_MEMORY, "mem %p: lock %d failed", mem, flags);
|
||||
memset (info, 0, sizeof (GstMapInfo));
|
||||
return FALSE;
|
||||
}
|
||||
error:
|
||||
|
@ -317,6 +318,7 @@ error:
|
|||
/* something went wrong, restore the orginal state again */
|
||||
GST_CAT_ERROR (GST_CAT_MEMORY, "mem %p: subclass map failed", mem);
|
||||
gst_memory_unlock (mem, (GstLockFlags) flags);
|
||||
memset (info, 0, sizeof (GstMapInfo));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue