Skip to content

Commit 45d3586

Browse files
committed
OS#18273047 - TVS: Warning 26007 in file: onecoreuap\inetcore\jscript\core\lib\runtime\base\scriptcontext.cpp
Prefast flagged some warnings around buffer lengths in ScriptContext.cpp. Fixed by adding SAL annotations to track the byte counts. Fixes: https://microsoft.visualstudio.com/OS/_workitems/edit/18273047 https://microsoft.visualstudio.com/OS/_workitems/edit/18281853
1 parent 0a1d70b commit 45d3586

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/Runtime/Base/ScriptContext.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,8 +2122,8 @@ namespace Js
21222122
_Inout_ uint& sourceIndex,
21232123
_In_ bool isCesu8,
21242124
_In_opt_ NativeModule* nativeModule,
2125-
_Out_ Js::ParseableFunctionInfo ** func,
2126-
_Out_ byte** parserStateCacheBuffer,
2125+
_Outptr_ Js::ParseableFunctionInfo ** func,
2126+
_Outptr_result_buffer_(*parserStateCacheByteCount) byte** parserStateCacheBuffer,
21272127
_Out_ DWORD* parserStateCacheByteCount,
21282128
_In_ Js::SimpleDataCacheWrapper* pDataCache)
21292129
{
@@ -2230,11 +2230,11 @@ namespace Js
22302230

22312231
HRESULT ScriptContext::TrySerializeParserState(
22322232
_In_ uint sourceCRC,
2233-
_In_ LPCUTF8 pszSrc,
2233+
_In_reads_bytes_(cbLength) LPCUTF8 pszSrc,
22342234
_In_ size_t cbLength,
22352235
_In_ SRCINFO *srcInfo,
22362236
_In_ Js::ParseableFunctionInfo* func,
2237-
_In_ byte* parserStateCacheBuffer,
2237+
_In_reads_bytes_(parserStateCacheByteCount) byte* parserStateCacheBuffer,
22382238
_In_ DWORD parserStateCacheByteCount,
22392239
_In_ Js::SimpleDataCacheWrapper* pDataCache)
22402240
{
@@ -2317,7 +2317,7 @@ namespace Js
23172317
__in Js::Utf8SourceInfo* utf8SourceInfo,
23182318
__in SRCINFO *srcInfo,
23192319
__in BOOL fOriginalUTF8Code,
2320-
__in LPCUTF8 pszSrc,
2320+
_In_reads_bytes_(cbLength) LPCUTF8 pszSrc,
23212321
__in size_t cbLength,
23222322
__in ULONG grfscr,
23232323
__in CompileScriptException *pse,

lib/Runtime/Base/ScriptContext.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,18 +1297,18 @@ namespace Js
12971297
_Inout_ uint& sourceIndex,
12981298
_In_ bool isCesu8,
12991299
_In_opt_ NativeModule* nativeModule,
1300-
_Out_ Js::ParseableFunctionInfo ** func,
1301-
_Out_ byte** parserStateCacheBuffer,
1300+
_Outptr_ Js::ParseableFunctionInfo ** func,
1301+
_Outptr_result_buffer_(*parserStateCacheByteCount) byte** parserStateCacheBuffer,
13021302
_Out_ DWORD* parserStateCacheByteCount,
13031303
_In_ Js::SimpleDataCacheWrapper* pDataCache);
13041304

13051305
HRESULT TrySerializeParserState(
13061306
_In_ uint sourceCRC,
1307-
_In_ LPCUTF8 pszSrc,
1307+
_In_reads_bytes_(cbLength) LPCUTF8 pszSrc,
13081308
_In_ size_t cbLength,
13091309
_In_ SRCINFO *srcInfo,
13101310
_In_ Js::ParseableFunctionInfo* func,
1311-
_In_ byte* parserStateCacheBuffer,
1311+
_In_reads_bytes_(parserStateCacheByteCount) byte* parserStateCacheBuffer,
13121312
_In_ DWORD parserStateCacheByteCount,
13131313
_In_ Js::SimpleDataCacheWrapper* pDataCache);
13141314

@@ -1317,7 +1317,7 @@ namespace Js
13171317
__in Js::Utf8SourceInfo* utf8SourceInfo,
13181318
__in SRCINFO *srcInfo,
13191319
__in BOOL fOriginalUTF8Code,
1320-
__in LPCUTF8 pszSrc,
1320+
_In_reads_bytes_(cbLength) LPCUTF8 pszSrc,
13211321
__in size_t cbLength,
13221322
__in ULONG grfscr,
13231323
__in CompileScriptException *pse,

0 commit comments

Comments
 (0)