diff --git a/gst-libs/gst/gl/gstglshader.c b/gst-libs/gst/gl/gstglshader.c index 218c0a8f54..05b4cafece 100644 --- a/gst-libs/gst/gl/gstglshader.c +++ b/gst-libs/gst/gl/gstglshader.c @@ -668,10 +668,12 @@ gst_gl_shader_release_unlocked (GstGLShader * shader) priv = shader->priv; - for (elem = shader->priv->stages; elem; elem = elem->next) { + for (elem = shader->priv->stages; elem;) { GstGLSLStage *stage = elem->data; + GList *next = elem->next; gst_gl_shader_detach_unlocked (shader, stage); + elem = next; } g_list_free_full (shader->priv->stages, (GDestroyNotify) gst_object_unref);