Skip to content

Commit c2b6a3c

Browse files
Silence PREfast false positive
Unfortunately, this needs the suppression despire the assert. Here we copy things into a buffer, and PREfast thinks that we may write beyond the buffer bounds, despite the analysis asserts.
1 parent c15e537 commit c2b6a3c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Runtime/Library/JavascriptProxy.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,7 @@ namespace Js
21452145
::Math::DefaultOverflowPolicy();
21462146
}
21472147
}
2148+
AnalysisAssert(newCount >= (ushort)args.Info.Count);
21482149

21492150
Var* newValues;
21502151
const unsigned STACK_ARGS_ALLOCA_THRESHOLD = 8; // Number of stack args we allow before using _alloca
@@ -2165,13 +2166,19 @@ namespace Js
21652166
calleeInfo.Flags = (CallFlags)(calleeInfo.Flags | CallFlags_ExtraArg | CallFlags_NewTarget);
21662167
}
21672168

2168-
for (uint argCount = 0; argCount < args.Info.Count; argCount++)
2169+
for (ushort argCount = 0; argCount < (ushort)args.Info.Count; argCount++)
21692170
{
2171+
AnalysisAssert(newCount >= ((ushort)args.Info.Count));
2172+
AnalysisAssert(argCount < newCount);
2173+
AnalysisAssert(argCount < (ushort)args.Info.Count);
2174+
AnalysisAssert(sizeof(Var*) == sizeof(void*));
2175+
AnalysisAssert(sizeof(Var*) * argCount < sizeof(void*) * newCount);
2176+
#pragma prefast(suppress:__WARNING_WRITE_OVERRUN, "This is a false positive, and all of the above analysis asserts still didn't convince prefast of that.")
21702177
newValues[argCount] = args.Values[argCount];
21712178
}
2172-
#pragma prefast(suppress:6386)
21732179
if (isNewCall)
21742180
{
2181+
AnalysisAssert(newCount == ((ushort)args.Info.Count) + 1);
21752182
newValues[args.Info.Count] = newTarget;
21762183
}
21772184

0 commit comments

Comments
 (0)