diff --git a/include/wx/buffer.h b/include/wx/buffer.h index 6d98f6e286..951777a13c 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -230,7 +230,8 @@ protected: static CharType *StrCopy(const CharType *src, size_t len) { CharType *dst = (CharType*)malloc(sizeof(CharType) * (len + 1)); - memcpy(dst, src, sizeof(CharType) * (len + 1)); + if ( dst ) + memcpy(dst, src, sizeof(CharType) * (len + 1)); return dst; } diff --git a/src/common/cmdline.cpp b/src/common/cmdline.cpp index 2952c2d6ae..bb5bd83b93 100644 --- a/src/common/cmdline.cpp +++ b/src/common/cmdline.cpp @@ -969,8 +969,8 @@ int wxCmdLineParser::Parse(bool showUsage) case wxCMD_LINE_VAL_DATE: { wxDateTime dt; - wxString::const_iterator end; - if ( !dt.ParseDate(value, &end) || end != value.end() ) + wxString::const_iterator endDate; + if ( !dt.ParseDate(value, &endDate) || endDate != value.end() ) { errorMsg << wxString::Format(_("Option '%s': '%s' cannot be converted to a date."), name.c_str(), value.c_str()) diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 3e51672eee..fda6c0ad52 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -514,7 +514,7 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const // (indirectly) set the year correctly while ( (nLostWeekDays % 7) != 0 ) { - nLostWeekDays += year++ % 4 ? 1 : 2; + nLostWeekDays += (year++ % 4) ? 1 : 2; } // finally move the year below 2000 so that the 2-digit @@ -1725,12 +1725,12 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end) if ( len > lenRest ) continue; - const wxString::const_iterator pEnd = p + len; - if ( wxString(p, pEnd).CmpNoCase(dateStr) == 0 ) + const wxString::const_iterator pEndStr = p + len; + if ( wxString(p, pEndStr).CmpNoCase(dateStr) == 0 ) { // nothing can follow this, so stop here - p = pEnd; + p = pEndStr; int dayDiffFromToday = literalDates[n].dayDiffFromToday; *this = Today(); @@ -1739,7 +1739,7 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end) *this += wxDateSpan::Days(dayDiffFromToday); } - *end = pEnd; + *end = pEndStr; return true; } diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index a05b15e438..2e04e80098 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1574,8 +1574,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); diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index f58ac30fd0..5e8304da52 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -834,7 +834,8 @@ wxChar32* wxStrdup(const wxChar32* s) { size_t size = (wxStrlen(s) + 1) * sizeof(wxChar32); wxChar32 *ret = (wxChar32*) malloc(size); - memcpy(ret, s, size); + if ( ret ) + memcpy(ret, s, size); return ret; } #endif diff --git a/src/msw/mimetype.cpp b/src/msw/mimetype.cpp index 3fbbbe983e..10ee1d0954 100644 --- a/src/msw/mimetype.cpp +++ b/src/msw/mimetype.cpp @@ -636,22 +636,23 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo) extWithDot = wxT('.'); extWithDot += ext; - wxRegKey key(wxRegKey::HKCR, extWithDot); - if ( !key.Exists() ) key.Create(); - key.SetValue(wxEmptyString, filetype); + wxRegKey key2(wxRegKey::HKCR, extWithDot); + if ( !key2.Exists() ) + key2.Create(); + key2.SetValue(wxEmptyString, filetype); // now set any mimetypes we may have, but ignore it if none - const wxString& mimetype = ftInfo.GetMimeType(); - if ( !mimetype.empty() ) + const wxString& mimetype2 = ftInfo.GetMimeType(); + if ( !mimetype2.empty() ) { // set the MIME type - ok = key.SetValue(wxT("Content Type"), mimetype); + ok = key2.SetValue(wxT("Content Type"), mimetype2); if ( ok ) { // create the MIME key wxString strKey = MIME_DATABASE_KEY; - strKey << mimetype; + strKey << mimetype2; wxRegKey keyMIME(wxRegKey::HKCR, strKey); ok = keyMIME.Create(); diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index b5e56d50f7..ce4b688f88 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -636,7 +636,8 @@ bool wxDoSetEnv(const wxString& var, const wxChar *value) envstr += '='; if ( value ) envstr += value; - _tputenv(envstr.t_str()); + if ( !_tputenv(envstr.t_str()) ) + return false; #else // other compiler if ( !::SetEnvironmentVariable(var.t_str(), value) ) { diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 416fe17562..cd3572e44d 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -996,7 +996,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler, // just launched process if ( !ddeServer.empty() ) { - bool ok; + bool ddeOK; // give the process the time to init itself // @@ -1015,15 +1015,15 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler, case WAIT_TIMEOUT: wxLogDebug(wxT("Timeout too small in WaitForInputIdle")); - ok = false; + ddeOK = false; break; case 0: // ok, process ready to accept DDE requests - ok = wxExecuteDDE(ddeServer, ddeTopic, ddeCommand); + ddeOK = wxExecuteDDE(ddeServer, ddeTopic, ddeCommand); } - if ( !ok ) + if ( !ddeOK ) { wxLogDebug(wxT("Failed to send DDE request to the process \"%s\"."), cmd.c_str()); diff --git a/src/msw/volume.cpp b/src/msw/volume.cpp index 397eb7e228..06c454ebc9 100644 --- a/src/msw/volume.cpp +++ b/src/msw/volume.cpp @@ -506,12 +506,13 @@ bool wxFSVolumeBase::Create(const wxString& name) if (!rc) { wxLogError(_("Cannot read typename from '%s'!"), m_volName.c_str()); - return m_isOk; + return false; } m_dispName = fi.szDisplayName; // all tests passed. - return m_isOk = true; + m_isOk = true; + return true; } // Create //=============================================================================