From 7f2e20627992042577222fcb474a093398a91c30 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 30 Sep 2020 14:41:08 +0200 Subject: Fix possible memory allocation error. --- src/drivers/Posix/Fl_Posix_System_Driver.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.cxx b/src/drivers/Posix/Fl_Posix_System_Driver.cxx index 9f255f3d0..0fa037b42 100644 --- a/src/drivers/Posix/Fl_Posix_System_Driver.cxx +++ b/src/drivers/Posix/Fl_Posix_System_Driver.cxx @@ -66,8 +66,11 @@ void *Fl_Posix_System_Driver::dlopen(const char *filename) ptr = double_dlopen(filename); # ifdef __APPLE_CC__ // allows testing on Darwin + XQuartz + fink if (!ptr) { - char *f_dylib = fl_strdup(filename); - strcpy(strrchr(f_dylib, '.'), ".dylib"); + char *f_dylib = (char*)malloc(strlen(filename)+7); + strcpy(f_dylib, filename); + char *p = strrchr(f_dylib, '.'); + if (!p) p = f_dylib + strlen(f_dylib); + strcpy(p, ".dylib"); char path[FL_PATH_MAX]; sprintf(path, "/sw/lib/%s", f_dylib); ptr = ::dlopen(path, RTLD_LAZY | RTLD_GLOBAL); -- cgit v1.2.3