|
|
commit 7f2e20627992042577222fcb474a093398a91c30
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Wed Sep 30 14:41:08 2020 +0200
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Wed Sep 30 14:41:19 2020 +0200
Fix possible memory allocation error.
src/drivers/Posix/Fl_Posix_System_Driver.cxx | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git src/drivers/Posix/Fl_Posix_System_Driver.cxx src/drivers/Posix/Fl_Posix_System_Driver.cxx
index 9f255f3..0fa037b 100644
--- src/drivers/Posix/Fl_Posix_System_Driver.cxx
+++ 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);
[ Direct Link to Message ] | |
|
| |