summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-09-30 14:41:08 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-09-30 14:41:19 +0200
commit7f2e20627992042577222fcb474a093398a91c30 (patch)
tree5b6b0c09d651f8ea002de180b2044aedc7d5fa0a /src
parent27c791ae8a03bd6fba732e9eb5cb1fc2d4262d21 (diff)
Fix possible memory allocation error.
Diffstat (limited to 'src')
-rw-r--r--src/drivers/Posix/Fl_Posix_System_Driver.cxx7
1 files changed, 5 insertions, 2 deletions
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);