X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/983aac2cdc670db63fe7c496e326e05d70a321dc..e87d78bb36f371d593137761158118fb09b69fa2:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index b1d98afaf8..f723d120db 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -61,6 +61,7 @@ #ifdef __WINDOWS__ #include "wx/msw/private.h" + #include "wx/msw/missing.h" #include "wx/msw/mslu.h" // sys/cygwin.h is needed for cygwin_conv_to_full_win32_path() @@ -742,11 +743,13 @@ wxPathOnly (wxChar *path) { static wxChar buf[_MAXPATHLEN]; - // Local copy - wxStrcpy (buf, path); - int l = wxStrlen(path); int i = l - 1; + if ( i >= _MAXPATHLEN ) + return NULL; + + // Local copy + wxStrcpy (buf, path); // Search backward for a backward or forward slash while (i > -1) @@ -788,12 +791,15 @@ wxString wxPathOnly (const wxString& path) { wxChar buf[_MAXPATHLEN]; - // Local copy - wxStrcpy(buf, path); - int l = path.length(); int i = l - 1; + if ( i >= _MAXPATHLEN ) + return wxString(); + + // Local copy + wxStrcpy(buf, path); + // Search backward for a backward or forward slash while (i > -1) { @@ -842,6 +848,9 @@ wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathCompon { CFURLRef fullURLRef; fullURLRef = CFURLCreateFromFSRef(NULL, fsRef); + if ( fullURLRef == NULL) + return wxEmptyString; + if ( additionalPathComponent ) { CFURLRef parentURLRef = fullURLRef ; @@ -1352,9 +1361,7 @@ wxString wxFindNextFile() wxCHECK_MSG( gs_dir, "", "You must call wxFindFirstFile before!" ); wxString result; - gs_dir->GetNext(&result); - - if ( result.empty() ) + if ( !gs_dir->GetNext(&result) || result.empty() ) { wxDELETE(gs_dir); return result; @@ -1383,7 +1390,7 @@ wxChar *wxDoGetCwd(wxChar *buf, int sz) buf = new wxChar[sz + 1]; } - bool ok wxDUMMY_INITIALIZE(false); + bool ok = false; // for the compilers which have Unicode version of _getcwd(), call it // directly, for the others call the ANSI version and do the translation @@ -1571,8 +1578,12 @@ wxString wxGetOSDirectory() #ifdef __WXWINCE__ return wxString(wxT("\\Windows")); #elif defined(__WINDOWS__) && !defined(__WXMICROWIN__) - wxChar buf[256]; - GetWindowsDirectory(buf, 256); + wxChar buf[MAX_PATH]; + if ( !GetWindowsDirectory(buf, MAX_PATH) ) + { + wxLogLastError(wxS("GetWindowsDirectory")); + } + return wxString(buf); #elif defined(__WXMAC__) && wxOSX_USE_CARBON return wxMacFindFolderNoSeparator(kOnSystemDisk, 'macs', false);