Author: bgbnbigben
Date: 2011-02-06 06:07:18 -0800 (Sun, 06 Feb 2011)
New Revision: 8388
Log:
Fixed a small bug that could cause a segfault if the user manually traversed to
/ in the FileChooser
Modified:
trunk/src/FileChooser2.cxx
Modified: trunk/src/FileChooser2.cxx
===================================================================
--- trunk/src/FileChooser2.cxx 2011-02-06 14:00:36 UTC (rev 8387)
+++ trunk/src/FileChooser2.cxx 2011-02-06 14:07:18 UTC (rev 8388)
@@ -238,10 +238,10 @@
if (f) {
// Update the current filename accordingly...
- char* pathname = new char [sizeof(directory_)]; // New pathname for
filename field
+ char pathname[1024]; // New pathname for filename field
- strlcpy(pathname, directory_, sizeof(directory_));
- if (pathname[0] && pathname[strlen(pathname) - 1] != '/')
+ strlcpy(pathname, directory_, sizeof(pathname));
+ if ((pathname[0] && pathname[strlen(pathname) - 1] != '/') || !pathname[0])
strlcat(pathname, "/", sizeof(pathname));
// Prevent users from cursing us: keep basename, if not a directory
if (!fltk::filename_isdir(fileName->text())) {
@@ -251,7 +251,6 @@
*dirptr = 0;
}
fileName->text(pathname);
- delete [] pathname;
}
if (shown()) {
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit