Avoid double-free in functions cloned for vulkan relaxed mode (#2987)
* Avoid double-free in functions cloned for vulkan relaxed mode When rewriting function calls atomicCounterIncrement and atoicCounterDecrement, clone the parameters so that the TParameter 'type' field is cloned. This avoids double-free when both the original and transformed functions are deleted by the parser. Fixes a ubsan failure.
This commit is contained in:
parent
f0ce653a25
commit
f28022c9f9
3 changed files with 9 additions and 6 deletions
|
|
@ -7035,12 +7035,14 @@ TIntermTyped* TParseContext::vkRelaxedRemapFunctionCall(const TSourceLoc& loc, T
|
|||
|
||||
TFunction realFunc(&name, function->getType());
|
||||
|
||||
// Use copyParam to avoid shared ownership of the 'type' field
|
||||
// of the parameter.
|
||||
for (int i = 0; i < function->getParamCount(); ++i) {
|
||||
realFunc.addParameter((*function)[i]);
|
||||
realFunc.addParameter(TParameter().copyParam((*function)[i]));
|
||||
}
|
||||
|
||||
TParameter tmpP = { 0, &uintType };
|
||||
realFunc.addParameter(tmpP);
|
||||
realFunc.addParameter(TParameter().copyParam(tmpP));
|
||||
arguments = intermediate.growAggregate(arguments, intermediate.addConstantUnion(1, loc, true));
|
||||
|
||||
result = handleFunctionCall(loc, &realFunc, arguments);
|
||||
|
|
@ -7053,11 +7055,11 @@ TIntermTyped* TParseContext::vkRelaxedRemapFunctionCall(const TSourceLoc& loc, T
|
|||
TFunction realFunc(&name, function->getType());
|
||||
|
||||
for (int i = 0; i < function->getParamCount(); ++i) {
|
||||
realFunc.addParameter((*function)[i]);
|
||||
realFunc.addParameter(TParameter().copyParam((*function)[i]));
|
||||
}
|
||||
|
||||
TParameter tmpP = { 0, &uintType };
|
||||
realFunc.addParameter(tmpP);
|
||||
realFunc.addParameter(TParameter().copyParam(tmpP));
|
||||
arguments = intermediate.growAggregate(arguments, intermediate.addConstantUnion(-1, loc, true));
|
||||
|
||||
result = handleFunctionCall(loc, &realFunc, arguments);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue