Fix for 134453: fix prefast warnings
authorRahul Kumar <rahku@microsoft.com>
Fri, 25 Sep 2015 21:03:54 +0000 (14:03 -0700)
committerMatt Ellis <matell@microsoft.com>
Sat, 26 Sep 2015 00:24:02 +0000 (17:24 -0700)
[tfs-changeset: 1529946]

43 files changed:
src/debug/shim/debugshim.cpp
src/inc/bbsweep.h
src/inc/clr/fs/path.h
src/inc/dlwrap.h
src/inc/downlevel.h
src/inc/eventtracebase.h
src/inc/formattype.cpp
src/inc/newapis.h
src/inc/sbuffer.h
src/inc/stgpool.h
src/inc/sxshelpers.h
src/inc/utilcode.h
src/inc/winrt/windowsstring.h
src/md/compressedinteger.h
src/md/datablob.h
src/md/datablob.inl
src/md/heaps/blobheap.h
src/md/hotdata/hotheap.h
src/utilcode/dlwrap.cpp
src/utilcode/downlevel.cpp
src/utilcode/posterror.cpp
src/utilcode/registrywrapper.cpp
src/utilcode/regutil.cpp
src/utilcode/securitywrapper.cpp
src/utilcode/sortversioning.cpp
src/utilcode/util.cpp
src/utilcode/util_nodependencies.cpp
src/utilcode/utilmessagebox.cpp
src/vm/appdomain.cpp
src/vm/assemblynativeresource.cpp
src/vm/ceeload.cpp
src/vm/clrprivbinderfusion.cpp
src/vm/clrprivbinderwinrt.cpp
src/vm/comdynamic.cpp
src/vm/comisolatedstorage.cpp
src/vm/compile.cpp
src/vm/dllimport.cpp
src/vm/dwbucketmanager.hpp
src/vm/excep.cpp
src/vm/mdaassistants.cpp
src/vm/securitymeta.cpp
src/vm/tlbexport.cpp
src/vm/util.cpp

index 2d4e63c..55b0b36 100644 (file)
@@ -84,10 +84,10 @@ STDMETHODIMP CLRDebuggingImpl::OpenVirtualProcess(
     HMODULE hDac = NULL;
     DWORD dbiTimestamp;
     DWORD dbiSizeOfImage;
-    WCHAR dbiName[MAX_PATH_FNAME];
+    WCHAR dbiName[MAX_PATH_FNAME] = {0};
     DWORD dacTimestamp;
     DWORD dacSizeOfImage;
-    WCHAR dacName[MAX_PATH_FNAME];
+    WCHAR dacName[MAX_PATH_FNAME] = {0};
     CLR_DEBUGGING_VERSION version;
     BOOL versionSupportedByCaller = FALSE;
     
index 7cebe20..f99c36c 100644 (file)
@@ -277,8 +277,8 @@ private:
             }
 #endif // !FEATURE_CORESYSTEM
 
-            WCHAR objectName[MAX_LONGPATH];
-            WCHAR objectNamePrefix[MAX_LONGPATH];
+            WCHAR objectName[MAX_LONGPATH] = {0};
+            WCHAR objectNamePrefix[MAX_LONGPATH] = {0};
             GetObjectNamePrefix(processID, fromRuntime, objectNamePrefix);
             // if there is a non-empty name prefix, append a '\'
             if (objectNamePrefix[0] != '\0')
index 29a70f7..e90b318 100644 (file)
@@ -92,7 +92,7 @@ namespace clr
             // result is placed in wzBuffer and the number of chars written is placed in pcchBuffer on
             // success; otherwise an error HRESULT is returned.
             static HRESULT
-            Combine(LPCWSTR wzPathLeft, LPCWSTR wzPathRight, __out DWORD *pcchBuffer, __out_ecount(*pcchBuffer) LPWSTR wzBuffer)
+            Combine(LPCWSTR wzPathLeft, LPCWSTR wzPathRight, __in DWORD *pcchBuffer, __out_ecount(*pcchBuffer) LPWSTR wzBuffer)
             {
                 STATIC_CONTRACT_NOTHROW;
 
index 9129bcf..d30e014 100644 (file)
@@ -42,6 +42,7 @@ VerQueryValueW_NoThrow(
 #endif
 
 #if defined(_WININET_) && !defined (CreateUrlCacheEntryW_NoThrow)
+__success(return) 
 BOOL 
 CreateUrlCacheEntryW_NoThrow(
         IN LPCWSTR lpszUrlName,
index 12aeb42..d33a0ab 100644 (file)
@@ -143,13 +143,14 @@ namespace DownLevel
     // User /system defaults
     // TODO: I don't think we need all of these.
     int GetSystemDefaultLocaleName(__out_ecount(cchLocaleName) LPWSTR lpLocaleName, __in int cchLocaleName);
-    DWORD GetUserPreferredUILanguages (__in DWORD dwFlags, __out PULONG pulNumLanguages, __out_ecount_opt(*pcchLanguagesBuffer) PWSTR pwszLanguagesBuffer, __in PULONG pcchLanguagesBuffer);
+    __success(return == 1) DWORD GetUserPreferredUILanguages (__in DWORD dwFlags, __out PULONG pulNumLanguages, __out_ecount_opt(*pcchLanguagesBuffer) PWSTR pwszLanguagesBuffer, __in PULONG pcchLanguagesBuffer);
     int GetUserDefaultLocaleName(__out_ecount(cchLocaleName) LPWSTR lpLocaleName, __in int cchLocaleName);
 
     // Locale and calendar information
     int GetLocaleInfoEx (__in LPCWSTR lpLocaleName, __in LCTYPE LCType, __out_ecount_opt(cchData) LPWSTR lpLCData, __in int cchData);    
     int GetDateFormatEx(__in LPCWSTR lpLocaleName, __in DWORD dwFlags, __in_opt CONST SYSTEMTIME* lpDate, __in_opt LPCWSTR lpFormat, 
                              __out_ecount(cchDate) LPWSTR lpDateStr, __in int cchDate, __in_opt LPCWSTR lpCalendar);    
+    __success(return != 0)
     int GetCalendarInfoEx(__in LPCWSTR lpLocaleName,
                           __in CALID Calendar,
                           __in_opt LPCWSTR pReserved,
@@ -160,12 +161,13 @@ namespace DownLevel
 
     // Compareinfo type information
     int TurkishCompareStringIgnoreCase(LCID lcid, DWORD dwCmpFlags, LPCWSTR lpString1, int cchCount1, LPCWSTR lpString2, int cchCount2);
-    
-    int CompareStringEx(LPCWSTR lpLocaleName, DWORD dwCmpFlags, LPCWSTR lpString1, int cchCount1, LPCWSTR lpString2,
-                                                int cchCount2, LPNLSVERSIONINFO lpVersionInformation,  LPVOID lpReserved,  LPARAM lParam );
 
-    int CompareStringOrdinal(LPCWSTR lpString1, int cchCount1, LPCWSTR lpString2, int cchCount2, BOOL bIgnoreCase);
+    int CompareStringEx(__in LPCWSTR lpLocaleName, __in DWORD dwCmpFlags, __in_ecount(cchCount1) LPCWSTR lpString1, __in int cchCount1, __in_ecount(cchCount2) LPCWSTR lpString2,
+                                                __in int cchCount2, __in_opt LPNLSVERSIONINFO lpVersionInformation, __in_opt LPVOID lpReserved, __in_opt LPARAM lParam );
+
+    int CompareStringOrdinal(__in_ecount(cchCount1) LPCWSTR string1, __in int cchCount1, __in_ecount(cchCount2) LPCWSTR string2, __in int cchCount2, __in BOOL bIgnoreCase);
 
+    __success(return != 0)
     int LCMapStringEx(__in LPCWSTR lpLocaleName, 
                       __in DWORD dwMapFlags, 
                       __in_ecount(cchSrc) LPCWSTR lpSrcStr, 
@@ -176,6 +178,7 @@ namespace DownLevel
                       __in_opt LPVOID lpReserved, 
                       __in_opt LPARAM lParam);
 
+    __success(return != -1)
     int FindNLSStringEx(__in LPCWSTR lpLocaleName,
                         __in DWORD dwFindNLSStringFlags,
                         __in_ecount(cchSource) LPCWSTR lpStringSource,
@@ -200,6 +203,7 @@ namespace DownLevel
     // This is where we fudge data the OS doesn't know (even on Vista)
     namespace UplevelFallback
     {
+        __success(return != 0)
         int LCMapStringEx(__in LPCWSTR lpLocaleName, 
                           __in DWORD dwMapFlags, 
                           __in_ecount(cchSrc) LPCWSTR lpSrcStr, 
@@ -225,6 +229,7 @@ namespace DownLevel
     
     int ResolveLocaleName(__in LPCWSTR lpNameToResolve, __in_ecount_opt(cchLocaleName) LPWSTR lpLocaleName, __in int cchLocaleName);    
 
+    __success(return)
     BOOL GetThreadPreferredUILanguages( __in DWORD dwFlags,
                                         __out PULONG pulNumLanguages,
                                         __out_ecount_opt(*pcchLanguagesBuffer) PWSTR pwszLanguagesBuffer,
index eac127e..9a6b218 100644 (file)
@@ -385,7 +385,7 @@ namespace ETW
         friend class ETW::EnumerationLog;
 #ifdef FEATURE_EVENT_TRACE
         static VOID SendModuleEvent(Module *pModule, DWORD dwEventOptions, BOOL bFireDomainModuleEvents=FALSE);
-        static ULONG SendModuleRange(Module *pModule, DWORD dwEventOptions);
+        static ULONG SendModuleRange(__in Module *pModule, __in DWORD dwEventOptions);
         static VOID SendAssemblyEvent(Assembly *pAssembly, DWORD dwEventOptions);
         static VOID SendDomainEvent(BaseDomain *pBaseDomain, DWORD dwEventOptions, LPCWSTR wszFriendlyName=NULL);
     public:
index 05b4c86..923ff3e 100644 (file)
@@ -93,7 +93,7 @@ const PCCOR_SIGNATURE PrettyPrintSignature(
     const char* name,                   // can be "", the name of the method for this sig 0 means local var sig 
     CQuickBytes *out,                   // where to put the pretty printed string   
     IMDInternalImport *pIMDI,           // ptr to IMDInternalImport class with ComSig
-    __in_opt const char* inlabel,       // prefix for names (NULL if no names required)
+       _In_opt_z_ const char* inlabel,       // prefix for names (NULL if no names required)
     BOOL printTyArity=FALSE);
 
 
index 0ec87b5..57286e2 100644 (file)
@@ -326,7 +326,9 @@ namespace NewApis
     // Enumeration functions
     __success(return != 0) BOOL
     EnumDateFormatsExEx (DATEFMT_ENUMPROCEXEX lpDateFmtEnumProcExEx, LPCWSTR lpLocaleName, DWORD dwFlags, LPARAM lParam);
+    __success(return != 0)
     BOOL EnumTimeFormatsEx(TIMEFMT_ENUMPROCEX lpTimeFmtEnumProcEx, LPCWSTR lpLocaleName,  DWORD dwFlags, LPARAM lParam);
+    __success(return != 0)
     BOOL EnumCalendarInfoExEx(CALINFO_ENUMPROCEXEX pCalInfoEnumProcExEx, LPCWSTR lpLocaleName, CALID Calendar, CALTYPE CalType, LPARAM lParam);
 
     int LCIDToLocaleName(__in LCID Locale, __out_ecount_opt(cchName) LPWSTR lpName, __in int cchName, __in DWORD dwFlags);
index adcde9b..0c98fdb 100644 (file)
@@ -353,8 +353,8 @@ class SBuffer
     // Manipulates contents of the buffer via the plugins below, but 
     // adds some debugging checks.  Should always call through here rather
     // than directly calling the extensibility points.
-    void DebugMoveBuffer(BYTE *to, BYTE *from, COUNT_T size);
-    void DebugCopyConstructBuffer(BYTE *to, const BYTE *from, COUNT_T size);
+    void DebugMoveBuffer(__out_bcount(size) BYTE *to, BYTE *from, COUNT_T size);
+    void DebugCopyConstructBuffer(__out_bcount(size) BYTE *to, const BYTE *from, COUNT_T size);
     void DebugConstructBuffer(BYTE *buffer, COUNT_T size);
     void DebugDestructBuffer(BYTE *buffer, COUNT_T size);
 
index 5932a51..9170125 100644 (file)
@@ -333,7 +333,7 @@ protected:
 //  helper for extension segments.
 //*****************************************************************************
     __checkReturn 
-    FORCEINLINE HRESULT GetDataReadOnly(UINT32 nOffset, __in MetaData::DataBlob *pData)
+    FORCEINLINE HRESULT GetDataReadOnly(UINT32 nOffset, __inout MetaData::DataBlob *pData)
     {
         LIMITED_METHOD_CONTRACT;
         _ASSERTE(IsReadOnly());
@@ -375,7 +375,7 @@ protected:
 //  helper for extension segments.
 //*****************************************************************************
     __checkReturn 
-    virtual HRESULT GetData(UINT32 nOffset, __in MetaData::DataBlob *pData)
+    virtual HRESULT GetData(UINT32 nOffset, __inout MetaData::DataBlob *pData)
     {
         WRAPPER_NO_CONTRACT;
         return GetDataReadOnly(nOffset, pData);
index 3fa450d..3ecf5cc 100644 (file)
@@ -103,7 +103,7 @@ class AssemblyVersion
         inline AssemblyVersion(AssemblyVersion& version);
         
         // Init
-        HRESULT Init(LPCWSTR pwzVersion, BOOL bStartsWithV);
+        HRESULT Init(__in_z LPCWSTR pwzVersion, BOOL bStartsWithV);
         inline HRESULT Init(WORD major, WORD minor, WORD build, WORD revision);
 
         // Mofifiers.
index 7d380e2..e832441 100644 (file)
@@ -5600,6 +5600,7 @@ namespace Clr { namespace Util
 namespace Reg
 {
     HRESULT ReadStringValue(HKEY hKey, LPCWSTR wszSubKey, LPCWSTR wszName, SString & ssValue);
+    __success(return == S_OK)
     HRESULT ReadStringValue(HKEY hKey, LPCWSTR wszSubKey, LPCWSTR wszName, __deref_out __deref_out_z LPWSTR* pwszValue);
 }
 
@@ -5625,6 +5626,7 @@ namespace Win32
         SString & ssFileName,
         bool fAllowLongFileNames = false);
 
+    __success(return == S_OK)
     HRESULT GetModuleFileName(
         HMODULE hModule,
         __deref_out_z LPWSTR * pwszFileName,
index ff5fcfe..fe99e69 100644 (file)
@@ -324,7 +324,7 @@ namespace clr
             //
             // if the HRESULT indicates failure, does nothing
             //
-            static HRESULT FreeAndAssignOnSuccess(HRESULT hr, HSTRING newValue, __out HSTRING *target)
+            static HRESULT FreeAndAssignOnSuccess(HRESULT hr, HSTRING newValue, __inout HSTRING *target)
             {
                 STATIC_CONTRACT_LIMITED_METHOD;
                 if (SUCCEEDED(hr))
index 54a86cb..2dcae9b 100644 (file)
@@ -67,6 +67,7 @@ public:
     // Returns FALSE if the value cannot be encoded as compressed integer, doesn't fill *pcbEncodingSize 
     // then.
     __checkReturn 
+    __success(return)
     static inline BOOL GetEncodingSize(
               UINT32  nValue, 
         __out UINT32 *pcbEncodingSize);
@@ -74,6 +75,7 @@ public:
     // *pcbEncodingSize with 1, 2 or 4 and *pnEncodedValue with the encoded value.
     // Returns FALSE if the value cannot be encoded as compressed integer, doesn't fill *pcbEncodingSize 
     // nor *pnEncodedValue then.
+    __success(return)
     static inline BOOL Encode(
               UINT32  nValue, 
         __out UINT32 *pnEncodedValue, 
index 891e41e..8e00b29 100644 (file)
@@ -67,19 +67,19 @@ public:
     // Returns FALSE if there's not enough data in the blob, doesn't initialize the value '*pnValue' then.
     // Returns TRUE otherwise, fills *pnValue, but doesn't move the memory block (doesn't skip the read 
     // data).
-    __checkReturn inline BOOL PeekU1(__out BYTE   *pnValue) const;
-    __checkReturn inline BOOL PeekU2(__out UINT16 *pnValue) const;
-    __checkReturn inline BOOL PeekU4(__out UINT32 *pnValue) const;
-    __checkReturn inline BOOL PeekU8(__out UINT64 *pnValue) const;
+    __checkReturn __success(return) inline BOOL PeekU1(__out BYTE   *pnValue) const;
+    __checkReturn __success(return) inline BOOL PeekU2(__out UINT16 *pnValue) const;
+    __checkReturn __success(return) inline BOOL PeekU4(__out UINT32 *pnValue) const;
+    __checkReturn __success(return) inline BOOL PeekU8(__out UINT64 *pnValue) const;
     
     //#GetUx_Functions
     // Reads the U1/U2/U4/U8 from the data blob and skips the read data.
     // Returns FALSE if there's not enough data in the blob, doesn't initialize the value '*pnValue' then.
     // Returns TRUE otherwise, fills *pnValue and moves the memory block behind the read data.
-    __checkReturn inline BOOL GetU1(__out BYTE   *pnValue);
-    __checkReturn inline BOOL GetU2(__out UINT16 *pnValue);
-    __checkReturn inline BOOL GetU4(__out UINT32 *pnValue);
-    __checkReturn inline BOOL GetU8(__out UINT64 *pnValue);
+    __checkReturn __success(return) inline BOOL GetU1(__out BYTE   *pnValue);
+    __checkReturn __success(return) inline BOOL GetU2(__out UINT16 *pnValue);
+    __checkReturn __success(return) inline BOOL GetU4(__out UINT32 *pnValue);
+    __checkReturn __success(return) inline BOOL GetU8(__out UINT64 *pnValue);
     
     // Reads compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format - returns the size 
     // in *pcbCompressedValueSize) from the data blob without skipping the read data.
@@ -89,6 +89,7 @@ public:
     // Returns TRUE otherwise, fills *pnValue and *pcbCompressedValueSize (with number 1,2 or 4), but 
     // doesn't move the memory block (doesn't skip the read data).
     __checkReturn 
+    __success(return)
     inline BOOL PeekCompressedU(
         __out UINT32 *pnValue, 
         __out UINT32 *pcbCompressedValueSize);
@@ -97,7 +98,8 @@ public:
     // Returns FALSE if there's not enough data in the blob or the compression is invalid (starts with byte 
     // 111? ????), doesn't initialize the value *pnValue then.
     // Returns TRUE otherwise, fills *pnValue and moves the memory block behind the read data.
-    __checkReturn 
+    __checkReturn
+    __success(return)
     inline BOOL GetCompressedU(__out UINT32 *pnValue);
     // Reads compressed integer (1, 2 or 4 bytes of format code:CompressedInteger#Format - returns the size 
     // in *pcbCompressedValueSize) from the data blob and skips the read data.
@@ -107,6 +109,7 @@ public:
     // Returns TRUE otherwise, fills *pnValue and *pcbCompressedValueSize (with number 1,2 or 4) and moves 
     // the memory block behind the read data.
     __checkReturn 
+    __success(return)
     inline BOOL GetCompressedU(
         __out UINT32 *pnValue, 
         __out UINT32 *pcbCompressedValueSize);
@@ -117,6 +120,7 @@ public:
     // Returns TRUE otherwise, fills *pData with the "read" data and moves the memory block behind the 
     // "read" data.
     __checkReturn 
+    __success(return)
     inline BOOL GetDataOfSize(
               UINT32    cbDataSize, 
         __out DataBlob *pData);
@@ -174,11 +178,13 @@ public:
     // Returns FALSE if there's less than cbSize data represented.
     // Returns TRUE otherwise and truncates the represented data size to cbSize.
     __checkReturn 
+    __success(return)
     inline BOOL TruncateToExactSize(UINT32 cbSize);
     // Truncates the buffer by size (cbSize).
     // Returns FALSE if there's less than cbSize data represented.
     // Returns TRUE otherwise and truncates the represented data size by cbSize.
     __checkReturn 
+    __success(return)
     inline BOOL TruncateBySize(UINT32 cbSize);
     
 #ifdef _DEBUG
@@ -198,12 +204,14 @@ public:
     // integer (bigger than code:CompressedInteger::const_Max).
     // Returns TRUE on success and moves the memory block behind the written data.
     __checkReturn 
+    __success(return)
     inline BOOL StoreCompressedU(UINT32 nValue);
     
     // Writes data from *pSource to the data blob and skips the written data.
     // Returns FALSE if there's not enough data in the blob.
     // Returns TRUE on success and moves memory block behind the written data.
     __checkReturn 
+    __success(return)
     inline BOOL StoreData(__in const DataBlob *pSource);
     
 private:
index d7ce361..40c92c2 100644 (file)
@@ -106,6 +106,7 @@ DataBlob::Init(
 // See code:#PeekUx_Functions above.
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::PeekU1(__out BYTE *pnValue) const
@@ -123,6 +124,7 @@ DataBlob::PeekU1(__out BYTE *pnValue) const
 // See code:#PeekUx_Functions above.
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::PeekU2(__out UINT16 *pnValue) const
@@ -140,6 +142,7 @@ DataBlob::PeekU2(__out UINT16 *pnValue) const
 // See code:#PeekUx_Functions above.
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::PeekU4(__out UINT32 *pnValue) const
@@ -157,6 +160,7 @@ DataBlob::PeekU4(__out UINT32 *pnValue) const
 // See code:#PeekUx_Functions above.
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::PeekU8(__out UINT64 *pnValue) const
@@ -183,6 +187,7 @@ DataBlob::PeekU8(__out UINT64 *pnValue) const
 // See code:#GetUx_Functions above.
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::GetU1(__out BYTE *pnValue)
@@ -201,6 +206,7 @@ DataBlob::GetU1(__out BYTE *pnValue)
 // See code:#GetUx_Functions above.
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::GetU2(__out UINT16 *pnValue)
@@ -219,6 +225,7 @@ DataBlob::GetU2(__out UINT16 *pnValue)
 // See code:#GetUx_Functions above.
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::GetU4(__out UINT32 *pnValue)
@@ -237,6 +244,7 @@ DataBlob::GetU4(__out UINT32 *pnValue)
 // See code:#GetUx_Functions above.
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::GetU8(__out UINT64 *pnValue)
@@ -278,6 +286,7 @@ DataBlob::GetCompressedU(__out UINT32 *pnValue)
 // doesn't move the memory block (doesn't skip the read data).
 // 
 __checkReturn 
+_Success_(return)
 inline 
 BOOL 
 DataBlob::PeekCompressedU(
index 91d5430..d3fb1e3 100644 (file)
@@ -83,7 +83,7 @@ public:
     
     __checkReturn 
     inline HRESULT GetAllData(
-        __out DataBlob *pData)
+        __inout DataBlob *pData)
     {
         return m_BlobPool.GetDataReadOnly(0, pData);
     }
index cc59c8a..e9e42c4 100644 (file)
@@ -52,7 +52,7 @@ public:
     __checkReturn 
     HRESULT GetData(
              UINT32    nDataIndex, 
-        __in DataBlob *pData);
+        __out DataBlob *pData);
     
     inline BOOL IsEmpty() const
         { return m_pHotHeapHeader == NULL; }
index f649e52..10acc61 100644 (file)
@@ -86,6 +86,7 @@ VerQueryValueW_NoThrow(
 //    is available, and then it will remove unused functions.
 // Instead of specifying all libs for imported functions needed by the following codes, we just
 // remove them from compiling phase.
+__success(return)
 BOOL 
 CreateUrlCacheEntryW_NoThrow(
         IN LPCWSTR lpszUrlName,
index 3b818e5..54d0955 100644 (file)
@@ -1810,6 +1810,7 @@ namespace DownLevel
         return cchSrc;
     }
 
+       __success(return != 0)
     int LinguisticCaseString(__in LCID lcid,__in DWORD flags,
                       __in_ecount(cchSrc) const WCHAR * source,
                       __in int cchSrc,
index 0ae48aa..e409695 100644 (file)
@@ -256,7 +256,7 @@ HRESULT FillErrorInfo(                  // Return status.
     }
     CONTRACTL_END;
 
-    ICreateErrorInfo *pICreateErr;      // Error info creation Iface pointer.
+    ICreateErrorInfo *pICreateErr = NULL;      // Error info creation Iface pointer.
     IErrorInfo *pIErrInfo = NULL;       // The IErrorInfo interface.
     HRESULT     hr;                     // Return status.
 
index e48fb09..96a1d6c 100644 (file)
@@ -217,10 +217,12 @@ HRESULT CheckUseWow6432Node(REGSAM samDesired, bool * fResult)
 // lpRedirectedKey is allocated and returned from this method.  Caller owns the new string and
 // should release
 //
+__success(return == ERROR_SUCCESS)
 HRESULT RedirectKey(REGSAM samDesired, HKEY hKey, LPCWSTR lpKey, __deref_out_z LPWSTR * lpRedirectedKey)
 {
     if (hKey != kRegistryRootHive || _wcsnicmp(lpKey, kRegistryRootKey, wcslen(kRegistryRootKey)) != 0)
     {
+        *lpRedirectedKey = NULL;
         return ERROR_SUCCESS;
     }
     
index c7c37aa..9fa98b0 100644 (file)
@@ -1130,8 +1130,8 @@ HRESULT REGUTIL::RegisterTypeLib(       // Return code.
     WCHAR       szID[64];               // The typelib ID to register.
     WCHAR       szTLBID[256];           // TypeLib\\szID.
     WCHAR       szHelpDir[_MAX_PATH];
-    WCHAR       szDrive[_MAX_DRIVE];
-    WCHAR       szDir[_MAX_DIR];
+    WCHAR       szDrive[_MAX_DRIVE] = {0};
+    WCHAR       szDir[_MAX_DIR] = {0};
     WCHAR       szVersion[64];
     LPWSTR      szTmp;
 
index 1fa8fca..f9d709c 100644 (file)
@@ -412,13 +412,14 @@ void SidBuffer::InitFromProcess(DWORD pid)
 HRESULT SidBuffer::InitFromProcessAppContainerSidNoThrow(DWORD pid)
 {
     HRESULT hr = S_OK;
+    HANDLE hToken = NULL;
+
     HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
     if (hProcess == NULL)
     {
         hr = HRESULT_FROM_GetLastError();
         goto exit;
     }
-    HANDLE hToken = NULL;
     if (!OpenProcessToken(hProcess, TOKEN_QUERY, &hToken))
     {
         hr = HRESULT_FROM_GetLastError();
index 6b9f56c..5f0d75b 100644 (file)
@@ -209,6 +209,7 @@ namespace SortVersioning
     }
 
     // Attempts to load a Sort DLL.  If this fails, the values of the __out parameters are unchanged.
+    __success(return)
     BOOL LoadSortDllAndPublish(
         __in  LPCWSTR sDllName, 
         __in  DWORD dwVersion, 
index e7d6a62..062cf61 100644 (file)
@@ -3783,6 +3783,7 @@ namespace Com
 {
     namespace __imp
     {
+        __success(return == S_OK)
         static
         HRESULT FindSubKeyDefaultValueForCLSID(REFCLSID rclsid, LPCWSTR wszSubKeyName, SString & ssValue)
         {
@@ -3803,6 +3804,7 @@ namespace Com
             return Clr::Util::Reg::ReadStringValue(HKEY_CLASSES_ROOT, ssKeyName.GetUnicode(), NULL, ssValue);
         }
 
+        __success(return == S_OK)
         static
         HRESULT FindSubKeyDefaultValueForCLSID(REFCLSID rclsid, LPCWSTR wszSubKeyName, __deref_out __deref_out_z LPWSTR* pwszValue)
         {
index 27720ae..9f4bc94 100644 (file)
@@ -516,7 +516,7 @@ HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString,
     }
 
     // Look in AeDebug key for "Debugger"; get the size of any value stored there.
-    DWORD valueType, valueSize;
+    DWORD valueType, valueSize = 0;
     ret = WszRegQueryValueEx(hKeyHolder, kUnmanagedDebuggerValue, 0, &valueType, 0, &valueSize);   
 
     _ASSERTE(pcchDebuggerString != NULL);
index f28d2d4..c196ddd 100644 (file)
@@ -190,7 +190,7 @@ int MessageBoxImpl(
         mustUseMessageBox = (pfnTaskDialogIndirect == NULL);
     }
 
-    int result;
+    int result = MB_OK;
     if (mustUseMessageBox) {
         result = WszMessageBox(hWnd, message, title, uType);
     }
index 0067f6b..aed588c 100644 (file)
@@ -8256,8 +8256,11 @@ public:
         }
         else
         {
-            IfFailRet(FString::Utf8_Unicode(szName, bIsAscii, wzBuffer, *pcchBuffer));
-            *pcchBuffer = cchName;
+            IfFailRet(FString::Utf8_Unicode(szName, bIsAscii, wzBuffer, cchBuffer));
+            if (pcchBuffer != nullptr)
+            {
+                *pcchBuffer = cchName;
+            }
             return S_OK;
         }
     }
index 2f13e2b..8c18299 100644 (file)
@@ -281,8 +281,8 @@ VOID Win32Res::WriteVerResource()
     WORD  cbStringBlocks;
     int i;
     bool bUseFileVer = false;
-    WCHAR       rcFile[_MAX_PATH];              // Name of file without path
-    WCHAR       rcFileExtension[_MAX_PATH];     // file extension
+    WCHAR       rcFile[_MAX_PATH] = {0};              // Name of file without path
+    WCHAR       rcFileExtension[_MAX_PATH] = {0};     // file extension
     WCHAR       rcFileName[_MAX_PATH];          // Name of file with extension but without path
     DWORD       cbTmp;
 
index b379d94..714547b 100644 (file)
@@ -3068,7 +3068,7 @@ BOOL Module::IsRuntimeWrapExceptions()
         if (hr == S_OK)
         {
             CustomAttributeParser ca(pVal, cbVal);
-            CaNamedArg namedArgs[1];
+            CaNamedArg namedArgs[1] = {0};
             
             // First, the void constructor:
             IfFailGo(ParseKnownCaArgs(ca, NULL, 0));
index aedecde..8b27d79 100644 (file)
@@ -232,7 +232,7 @@ public:
 
 
     STDMETHOD(GetName)(
-        __out LPDWORD lpcwBuffer,
+        __inout LPDWORD lpcwBuffer,
         __out_ecount_opt(*lpcwBuffer) WCHAR *pwzName)
     {
         LIMITED_METHOD_CONTRACT;
index dc6556a..1532943 100644 (file)
@@ -390,7 +390,7 @@ HRESULT CLRPrivBinderWinRT::BindWinRTAssemblyByName(
             const WCHAR * wszFileName = pFileNameElem->GetValue();
             pAssembly = FindAssemblyByFileName(wszFileName);
             
-            WCHAR wszFileNameStripped[_MAX_PATH];
+            WCHAR wszFileNameStripped[_MAX_PATH] = {0};
             SplitPath(wszFileName, NULL, NULL, NULL, NULL, wszFileNameStripped, _MAX_PATH, NULL, NULL);
 
             if (pAssembly == nullptr)
index 13be5f7..28bf7ab 100644 (file)
@@ -1404,7 +1404,7 @@ HRESULT COMDynamicWrite::EmitDebugInfoBegin(Module *pModule,
     // and fill out the debug directory and save off the symbols now.
     if (pWriter != NULL)
     {
-        IMAGE_DEBUG_DIRECTORY  debugDirIDD;
+        IMAGE_DEBUG_DIRECTORY  debugDirIDD = {0};
         DWORD                  debugDirDataSize;
         BYTE                  *debugDirData;
 
index 50eb9fe..abdcb9b 100644 (file)
@@ -312,7 +312,7 @@ void QCALLTYPE COMIsolatedStorageFile::GetRootDir(DWORD                      dwF
     QCALL_CONTRACT;
     BEGIN_QCALL;
 
-    WCHAR wszPath[MAX_LONGPATH + 1];
+    WCHAR wszPath[MAX_LONGPATH + 1] = {0};
     GetRootDirInternal(dwFlags, wszPath, COUNTOF(wszPath));
     retRootDir.Set(wszPath);
 
index cf1d399..0cb474e 100644 (file)
@@ -759,9 +759,9 @@ HRESULT CEECompileInfo::LoadTypeRefWinRT(
         Assembly *pAssembly;
 
         mdToken tkResolutionScope;
-        pAssemblyImport->GetResolutionScopeOfTypeRef(ref, &tkResolutionScope);
-        
-        if(TypeFromToken(tkResolutionScope) == mdtAssemblyRef)
+        if(FAILED(pAssemblyImport->GetResolutionScopeOfTypeRef(ref, &tkResolutionScope)))
+            hr = S_FALSE;
+        else if(TypeFromToken(tkResolutionScope) == mdtAssemblyRef)
         {
             DWORD dwAssemblyRefFlags;
             IfFailThrow(pAssemblyImport->GetAssemblyRefProps(tkResolutionScope, NULL, NULL,
index df0f9bf..f6fabde 100644 (file)
@@ -4031,7 +4031,7 @@ struct HiddenParameterInfo
 void CheckForHiddenParameters(DWORD cParamMarshalInfo,
                               __in_ecount(cParamMarshalInfo) MarshalInfo *pParamMarshalInfo,
                               __out DWORD *pcHiddenNativeParameters,
-                              __out_ecount(*pcHiddenNativeParameters) HiddenParameterInfo **ppHiddenNativeParameters)
+                              __out HiddenParameterInfo **ppHiddenNativeParameters)
 {
     CONTRACTL
     {
index 11d56de..abcc6f3 100644 (file)
@@ -513,7 +513,7 @@ void BaseBucketParamsManager::GetAppVersion(__out_ecount(maxLength) WCHAR* targe
     WCHAR appPath[MAX_LONGPATH];
     DWORD cchAppPath = NumItems(appPath);
 
-    WCHAR verBuf[23];
+    WCHAR verBuf[23] = {0};
     USHORT major, minor, build, revision;
 
     if ((GetCurrentModuleFileName(appPath, &cchAppPath) == S_OK) && SUCCEEDED(DwGetFileVersionInfo(appPath, major, minor, build, revision)))
index 7b4899d..a8a8b16 100644 (file)
@@ -5868,7 +5868,7 @@ DefaultCatchHandler(PEXCEPTION_POINTERS pExceptionPointers,
     }
 
     const int buf_size = 128;
-    WCHAR buf[buf_size];
+    WCHAR buf[buf_size] = {0};
 
     // See detailed explanation of this flag in threads.cpp.  But the basic idea is that we already
     // reported the exception in the AppDomain where it went unhandled, so we don't need to report
index 38c38d8..cac15fd 100644 (file)
@@ -996,7 +996,11 @@ void MdaPInvokeLog::LogPInvoke(NDirectMethodDesc* pMD, HINSTANCE hMod)
         StackSString sszEntryPoint;
         sszEntryPoint.SetUTF8(pMD->GetEntrypointName());
 
-        WCHAR szDllFullName[_MAX_PATH], szDrive[_MAX_PATH], szPath[_MAX_PATH], szFileName[_MAX_PATH], szExt[_MAX_PATH];
+        WCHAR szDllFullName[_MAX_PATH] = {0};
+        WCHAR szDrive[_MAX_PATH] = {0};
+        WCHAR szPath[_MAX_PATH] = {0};
+        WCHAR szFileName[_MAX_PATH] = {0};
+        WCHAR szExt[_MAX_PATH] = {0};
         WszGetModuleFileName(hMod, szDllFullName, _MAX_PATH);      
         SplitPath(szDllFullName, szDrive, _MAX_PATH, szPath, _MAX_PATH, szFileName, _MAX_PATH, szExt, _MAX_PATH);
 
index b46ac44..9c7e447 100644 (file)
@@ -1834,7 +1834,7 @@ TokenSecurityDescriptorFlags ParseAptcaAttribute(const BYTE *pbAptcaBlob, DWORD
         aptcaFlags |= TokenSecurityDescriptorFlags_APTCA;
 
         // Look for the PartialTrustVisibilityLevel named argument
-        CaNamedArg namedArgs[1];
+        CaNamedArg namedArgs[1] = {0};
         namedArgs[0].InitI4FieldEnum(g_PartialTrustVisibilityLevel, g_SecurityPartialTrustVisibilityLevel);
 
         if (SUCCEEDED(ParseKnownCaNamedArgs(cap, namedArgs, _countof(namedArgs))))
index 1786138..7446710 100644 (file)
@@ -277,10 +277,10 @@ void ExportTypeLibFromLoadedAssembly(
 
     TypeLibExporter exporter;           // Exporter object.
     LPCWSTR     szModule=0;             // Module filename.
-    WCHAR       rcDrive[_MAX_DRIVE];
-    WCHAR       rcDir[_MAX_DIR];
-    WCHAR       rcFile[_MAX_FNAME];
-    WCHAR       rcTlb[_MAX_PATH+5];     // Buffer for the tlb filename.
+    WCHAR       rcDrive[_MAX_DRIVE] = {0};
+    WCHAR       rcDir[_MAX_DIR] = {0};
+    WCHAR       rcFile[_MAX_FNAME] = {0};
+    WCHAR       rcTlb[_MAX_PATH+5] = {0};     // Buffer for the tlb filename.
     int         bDynamic=0;             // If true, dynamic module.
     Module      *pModule;               // The Assembly's SecurityModule.
     
index 9c13540..f823aa9 100644 (file)
@@ -31,7 +31,7 @@
 // Called again with a nonnull *pdstout to fill in the actual buffer.
 //
 // Returns the # of arguments.
-static UINT ParseCommandLine(LPCWSTR psrc, __out LPWSTR *pdstout)
+static UINT ParseCommandLine(LPCWSTR psrc, __inout LPWSTR *pdstout)
 {
     CONTRACTL
     {