summaryrefslogtreecommitdiff
path: root/ivi-shell
diff options
context:
space:
mode:
authorMichael Tretter <m.tretter@pengutronix.de>2022-09-28 12:17:29 +0200
committerMichael Tretter <m.tretter@pengutronix.de>2022-10-19 14:16:06 +0200
commitc56e69bc850540f243ebb87c5bcc38713ef1862a (patch)
treec46c9f5062097312a1641e8f4cff8e51ecee320f /ivi-shell
parent2f0be4b4d0971fc876768d0e38dcd34d24f0960f (diff)
downloadweston-c56e69bc850540f243ebb87c5bcc38713ef1862a.tar.gz
ivi-shell: fix free in get_layers_under_surface
If a controller requests the layers under a surface that has no views attached, Weston crashes since it tries to free the array that would be used to return the found layers, but has not been allocated before. Free the ppArray only if it was allocated in ivi_layout_get_layers_under_surface before and no layers were found. While at it, make it obvious that checking the length is an integer comparison by comparing it to 0. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Diffstat (limited to 'ivi-shell')
-rw-r--r--ivi-shell/ivi-layout.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 2a7ff529..9e9ad338 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -1194,15 +1194,14 @@ ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
else
length--;
}
+ if (length == 0) {
+ free(*ppArray);
+ *ppArray = NULL;
+ }
}
*pLength = length;
- if (!length) {
- free(*ppArray);
- *ppArray = NULL;
- }
-
return IVI_SUCCEEDED;
}