-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix undefined behaviour #646
Changes from all commits
56bb999
89f6b8a
13e3aa9
0352710
5c77c92
fe550f3
8074b72
61637d3
be1eedf
760ea43
df9b45a
9dcf51c
05f0592
c52cec7
21acc56
8c40597
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,9 +413,11 @@ class Schema { | |
} | ||
} | ||
|
||
AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document); | ||
AssignIfExist(anyOf_, *schemaDocument, p, value, GetAnyOfString(), document); | ||
AssignIfExist(oneOf_, *schemaDocument, p, value, GetOneOfString(), document); | ||
if (schemaDocument) { | ||
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. This seems unncessary? 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. schemaDocument is NULL for the Schema returned by Schema::GetTypeless(). |
||
AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document); | ||
AssignIfExist(anyOf_, *schemaDocument, p, value, GetAnyOfString(), document); | ||
AssignIfExist(oneOf_, *schemaDocument, p, value, GetOneOfString(), document); | ||
} | ||
|
||
if (const ValueType* v = GetMember(value, GetNotString())) { | ||
schemaDocument->CreateSchema(¬_, p.Append(GetNotString(), allocator_), *v, document); | ||
|
@@ -578,7 +580,9 @@ class Schema { | |
} | ||
|
||
~Schema() { | ||
allocator_->Free(enum_); | ||
if (allocator_) { | ||
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.
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. allocator_ is NULL for the Schema returned by Schema::GetTypeless(). The destructor is dereferencing the NULL when the global static is torn down during shutdown. |
||
allocator_->Free(enum_); | ||
} | ||
if (properties_) { | ||
for (SizeType i = 0; i < propertyCount_; i++) | ||
properties_[i].~Property(); | ||
|
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.
Was this cause array out of bound?
Otherwise should change to
size_t
andassert(kappa <= 0)
?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.
I added a test case that causes index to be 13. It's an overflow, not an underflow.
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.
I want to ask a question here. Since the array kPow10 is of length 10, why not check "index < 10" here? If index is 9, then it is still safe to access kPow10[9]. @efidler