If the constructor fails before the lists are initialized the deconstructor will fail.
This patch is a bit of a kludge fix to just avoid the undefined behaviour. The real fix down the road would be to avoid calling the deconstructor if the constructor failed at all. Tom
From 3cf2f8e32b7093c0342a09a9b20de798f3a0e4f9 Mon Sep 17 00:00:00 2001 From: Tom St Denis <tom.stde...@amd.com> Date: Tue, 3 Nov 2015 12:41:54 -0500 Subject: [PATCH] Avoid segfault in deconstructor if constructor fails If the constructor fails before the LIST_INIT calls the pointers will be null and the deconstructor will segfault. Signed-off-by: Tom St Denis <tstde...@amd.com> Reviewed-by: Leo Liu <leo....@amd.com> --- src/gallium/state_trackers/omx/vid_enc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c index 2bd0194189f1..f1f187ce9f7c 100644 --- a/src/gallium/state_trackers/omx/vid_enc.c +++ b/src/gallium/state_trackers/omx/vid_enc.c @@ -869,6 +869,9 @@ static void enc_ReleaseTasks(struct list_head *head) { struct encode_task *i, *next; + if (!head) + return; + LIST_FOR_EACH_ENTRY_SAFE(i, next, head, list) { pipe_resource_reference(&i->bitstream, NULL); i->buf->destroy(i->buf); -- 2.6.2
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev