FLTK logo

[master] 7f2e206 - Fix possible memory allocation error.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 7f2e206 - Fix possible memory allocation error. "ManoloFLTK" Sep 30, 2020  
 
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 ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.