summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeka Friedrich <friedrix@gmail.com>2022-02-20 22:51:59 +0100
committerJeka Friedrich <friedrix@gmail.com>2022-02-20 22:51:59 +0100
commitf6911a11dc911a5bcb380d0895db6cfd533a3569 (patch)
tree344a492a93170446ef531688e950af66c4a795ba
parent2230f59949cfe8ff9e83993704943a168d969908 (diff)
parent08a655a883aa837cf1de05fdaf0d371c4af8e404 (diff)
downloadwayland-ivi-extension-f6911a11dc911a5bcb380d0895db6cfd533a3569.tar.gz
Merge remote-tracking branch 'upstream/pull/124'
* upstream/pull/124 EGLWLInputEventExample: Repair array out of bounds access simple-weston-client: Repair array out of bounds access Reviewed-by: Eugen Friedrich <efriedrich@de.adit-jv.com> Tested-by: Eugen Friedrich <efriedrich@de.adit-jv.com>
-rw-r--r--ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp5
-rw-r--r--ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c6
2 files changed, 7 insertions, 4 deletions
diff --git a/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp b/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp
index ade58f0..dedb5a8 100644
--- a/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp
+++ b/ivi-layermanagement-examples/EGLWLInputEventExample/src/WLContext.cpp
@@ -64,6 +64,7 @@ WLContext::~WLContext()
* The following correspondences between file names and cursors was copied
* from: https://bugs.kde.org/attachment.cgi?id=67313
*/
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
static const char *left_ptrs[] = {
"left_ptr",
@@ -86,12 +87,12 @@ create_cursors(WLContext* wlContext)
}
wlContext->SetWLCursor((wl_cursor*) malloc(sizeof(wl_cursor)));
- for (j = 0; !cursor && j < 4; ++j)
+ for (j = 0; !cursor && j < ARRAY_SIZE(left_ptrs); ++j)
cursor = wl_cursor_theme_get_cursor(wlContext->GetWLCursorTheme(),
left_ptrs[j]);
if (!cursor)
- fprintf(stderr, "could not load cursor '%s'\n", left_ptrs[j]);
+ fprintf(stderr, "could not load any cursor\n");
wlContext->SetWLCursor(cursor);
}
diff --git a/ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c b/ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c
index ab63390..a0632c7 100644
--- a/ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c
+++ b/ivi-layermanagement-examples/simple-weston-client/src/simple-weston-client.c
@@ -99,6 +99,8 @@ struct debug_stream {
struct weston_debug_stream_v1 *obj;
};
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
static const char *left_ptrs[] = {
"left_ptr",
"default",
@@ -271,12 +273,12 @@ static int create_cursors(WaylandContextStruct* wlcontext) {
wlcontext->cursor = NULL;
- for (j = 0; !wlcontext->cursor && j < 4; ++j)
+ for (j = 0; !wlcontext->cursor && j < ARRAY_SIZE(left_ptrs); ++j)
wlcontext->cursor = wl_cursor_theme_get_cursor(wlcontext->cursor_theme, left_ptrs[j]);
if (!wlcontext->cursor)
{
- fprintf(stderr, "could not load cursor '%s'\n", left_ptrs[j]);
+ fprintf(stderr, "could not load any cursor\n");
return -1;
}