summaryrefslogtreecommitdiff
path: root/src/Fl_Native_File_Chooser_WIN32.cxx
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2014-01-06 01:01:52 +0000
committerGreg Ercolano <erco@seriss.com>2014-01-06 01:01:52 +0000
commit8ecd7a1abb19f15dcd9761bfe8c1f80f6600231d (patch)
treefbfbb7f7c7b2727cd9d35f1a030079237513df2d /src/Fl_Native_File_Chooser_WIN32.cxx
parenteb980231be4d3cb93b306cdf3b133ff326abad8d (diff)
Fix mem leak with 'oldcwd' if user hits 'cancel' button in browser..
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10045 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Native_File_Chooser_WIN32.cxx')
-rw-r--r--src/Fl_Native_File_Chooser_WIN32.cxx25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/Fl_Native_File_Chooser_WIN32.cxx b/src/Fl_Native_File_Chooser_WIN32.cxx
index bc823eb1b..0376c54ac 100644
--- a/src/Fl_Native_File_Chooser_WIN32.cxx
+++ b/src/Fl_Native_File_Chooser_WIN32.cxx
@@ -376,27 +376,22 @@ int Fl_Native_File_Chooser::showfile() {
} else {
err = GetOpenFileNameW(&_ofn);
}
+ // GET EXTENDED ERROR
+ int exterr = CommDlgExtendedError();
+ // XXX: RESTORE CWD
+ if ( oldcwd ) {
+ SetCurrentDirectory(oldcwd);
+ free(oldcwd); oldcwd = 0;
+ }
+ // ERROR OR CANCEL?
if ( err == 0 ) {
- // EXTENDED ERROR CHECK
- int err = CommDlgExtendedError();
- // CANCEL?
- if ( err == 0 ) return(1); // user hit 'cancel'
- // AN ERROR OCCURRED
+ if ( exterr == 0 ) return(1); // user hit cancel
+ // Otherwise, an error occurred..
char msg[80];
sprintf(msg, "CommDlgExtendedError() code=%d", err);
errmsg(msg);
- // XXX: RESTORE CWD
- if ( oldcwd ) {
- SetCurrentDirectory(oldcwd);
- free(oldcwd); oldcwd = 0;
- }
return(-1);
}
- // XXX: RESTORE CWD
- if ( oldcwd ) {
- SetCurrentDirectory(oldcwd);
- free(oldcwd); oldcwd = 0;
- }
// PREPARE PATHNAMES FOR RETURN
switch ( _btype ) {
case BROWSE_FILE: