Fix mismatched memory allocation and deallocation. (#6923)
In NestedNameSpecifier.cpp, the Append function allocates data using `new`:e1bb926f63/tools/clang/lib/AST/NestedNameSpecifier.cpp (L449-L450)
However, if it deallocated using `free`:e1bb926f63/tools/clang/lib/AST/NestedNameSpecifier.cpp (L514-L516)
This can cause problems. I'm changing the `free` to `delete`.
This commit is contained in:
Родитель
9f298d6fa2
Коммит
26ea670d97
|
@ -512,7 +512,7 @@ operator=(const NestedNameSpecifierLocBuilder &Other) {
|
|||
|
||||
// Free our storage, if we have any.
|
||||
if (BufferCapacity) {
|
||||
free(Buffer);
|
||||
delete[] Buffer; // HLSL Change: Use overridable operator delete
|
||||
BufferCapacity = 0;
|
||||
}
|
||||
|
||||
|
@ -647,7 +647,7 @@ void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
|
|||
|
||||
void NestedNameSpecifierLocBuilder::Adopt(NestedNameSpecifierLoc Other) {
|
||||
if (BufferCapacity)
|
||||
free(Buffer);
|
||||
delete[] Buffer; // HLSL Change: Use overridable operator delete
|
||||
|
||||
if (!Other) {
|
||||
Representation = nullptr;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// RUN: %dxc -T cs_6_0 -E main -HV 2021 -verify %s
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
template <typename T>
|
||||
class C {
|
||||
C cast();
|
||||
};
|
||||
|
||||
template <class T>
|
||||
C<T>
|
||||
C<T>::cast() {
|
||||
C result;
|
||||
return result;
|
||||
}
|
||||
|
||||
[numthreads(64, 1, 1)] void main() {}
|
Загрузка…
Ссылка в новой задаче