summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tretter <m.tretter@pengutronix.de>2022-09-28 12:17:29 +0200
committerMarius Vlad <marius.vlad@collabora.com>2022-11-21 13:55:20 +0200
commit72a692946755ef50ef9ca64369a833c89c738361 (patch)
tree2cad81f92c0efa56b93ba254f91deadcf8a0fce8
parent7a8392d2fe702880eaf33d161652bdddcc998d74 (diff)
downloadweston-72a692946755ef50ef9ca64369a833c89c738361.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> (cherry picked from commit c56e69bc850540f243ebb87c5bcc38713ef1862a)
-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 1c42d636..9f861a38 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -1192,15 +1192,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;
}