-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add guard word before local var CMiniColDef[9] #73736
Closed
RobertHenry6bev
wants to merge
2
commits into
dotnet:main
from
RobertHenry6bev:robhenry-guard-local-array-4
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -717,7 +717,17 @@ CMiniMdBase::InitColsForTable( | |
// should we write the data into the structure | ||
{ | ||
const CMiniTableDef *pTemplate; // Template table definition. | ||
CMiniColDef pCols[9]; // The col defs to init. | ||
const int MaxCols = 9; | ||
typedef uint32_t markword_t; | ||
BYTE tempCols[sizeof(markword_t) + MaxCols * sizeof(CMiniColDef)]; // keep aligned | ||
|
||
_ASSERTE(MaxCols >= pTable->m_cCols); | ||
// | ||
// Mark the array of columns as not allocated (eg, not ALLOCATED_MEMORY_MARKER) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E.g. means “for example”. Did you actually mean "i.e."? |
||
// for SetNewColumnDefinition call | ||
// | ||
memset(tempCols, 0, sizeof(markword_t)); | ||
CMiniColDef *pCols = BYTEARRAY_TO_COLDES(tempCols + sizeof(markword_t) - 1); // The col defs to init. | ||
BYTE iOffset; // Running size of a record. | ||
BYTE iSize; // Size of a field. | ||
HRESULT hr = S_OK; | ||
|
@@ -726,10 +736,8 @@ CMiniMdBase::InitColsForTable( | |
_ASSERTE(ARRAY_SIZE(pCols) >= pTable->m_cCols); | ||
|
||
bExtra = 0;//<TODO>@FUTURE: save in schema header. until then use 0.</TODO> | ||
|
||
iOffset = 0; | ||
|
||
pTemplate = GetTableDefTemplate(ixTbl); | ||
pTemplate = GetTableDefTemplate(ixTbl); | ||
|
||
PREFIX_ASSUME(pTemplate->m_pColDefs != NULL); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use a single-byte marker everywhere in this code. I see no reason to use four bytes just at this particular place. This array contains 3-byte structures, so you cannot align them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is similar code in another function:
runtime/src/coreclr/md/enc/metamodelrw.cpp
Lines 3635 to 3638 in 2201016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here:
runtime/src/coreclr/md/runtime/metamodel.cpp
Lines 880 to 889 in 4710133