mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
msdk: avoid reading data from freed memory
Both g_list_delete_link and g_list_remove remove an element and free it, so l->next is invalid (catched by valgrind) after calling g_list_delete_link or g_list_remove
This commit is contained in:
parent
fa18824d32
commit
4841c2759d
3 changed files with 11 additions and 6 deletions
|
@ -468,8 +468,9 @@ check_surfaces_available (GstMsdkContext * context, GstMsdkAllocResponse * resp)
|
|||
gboolean ret = FALSE;
|
||||
|
||||
g_mutex_lock (&priv->mutex);
|
||||
for (l = resp->surfaces_locked; l; l = l->next) {
|
||||
for (l = resp->surfaces_locked; l;) {
|
||||
surface = l->data;
|
||||
l = l->next;
|
||||
if (!surface->Data.Locked) {
|
||||
resp->surfaces_locked = g_list_remove (resp->surfaces_locked, surface);
|
||||
resp->surfaces_avail = g_list_prepend (resp->surfaces_avail, surface);
|
||||
|
@ -503,9 +504,9 @@ gst_msdk_context_get_surface_available (GstMsdkContext * context,
|
|||
|
||||
retry:
|
||||
g_mutex_lock (&priv->mutex);
|
||||
for (l = msdk_resp->surfaces_avail; l; l = l->next) {
|
||||
for (l = msdk_resp->surfaces_avail; l;) {
|
||||
surface = l->data;
|
||||
|
||||
l = l->next;
|
||||
if (!surface->Data.Locked) {
|
||||
msdk_resp->surfaces_avail =
|
||||
g_list_remove (msdk_resp->surfaces_avail, surface);
|
||||
|
|
|
@ -769,8 +769,9 @@ release_msdk_surfaces (GstMsdkDec * thiz)
|
|||
GList *l;
|
||||
MsdkSurface *surface;
|
||||
|
||||
for (l = thiz->decoded_msdk_surfaces; l; l = l->next) {
|
||||
for (l = thiz->decoded_msdk_surfaces; l;) {
|
||||
surface = l->data;
|
||||
l = l->next;
|
||||
free_surface (thiz, surface);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -647,15 +647,18 @@ gst_msdkenc_dequeue_frame (GstMsdkEnc * thiz, GstVideoCodecFrame * frame)
|
|||
{
|
||||
GList *l;
|
||||
|
||||
for (l = thiz->pending_frames; l; l = l->next) {
|
||||
for (l = thiz->pending_frames; l;) {
|
||||
FrameData *fdata = l->data;
|
||||
GList *l1 = l;
|
||||
|
||||
l = l->next;
|
||||
|
||||
if (fdata->frame != frame)
|
||||
continue;
|
||||
|
||||
gst_msdkenc_free_frame_data (thiz, fdata);
|
||||
|
||||
thiz->pending_frames = g_list_delete_link (thiz->pending_frames, l);
|
||||
thiz->pending_frames = g_list_delete_link (thiz->pending_frames, l1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue