From ce0ac4f29e720688ea94fbe412a0b332304d8ee6 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Thu, 12 Sep 2024 20:52:15 +0200 Subject: [PATCH] cursor: Gracefully handle out of memory condition If the full path could not be constructed, avoid calling opendir(NULL) which, depending on library, might trigger undefined behavior. Signed-off-by: Tobias Stoeckmann --- cursor/xcursor.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cursor/xcursor.c b/cursor/xcursor.c index b852a1f9..f7156cdb 100644 --- a/cursor/xcursor.c +++ b/cursor/xcursor.c @@ -686,11 +686,15 @@ load_all_cursors_from_dir(const char *path, int size, void *user_data) { FILE *f; - DIR *dir = opendir(path); + DIR *dir; struct dirent *ent; char *full; struct xcursor_images *images; + if (!path) + return; + + dir = opendir(path); if (!dir) return;