Merge pull request #111 from dneto0/issue-110-frexp-fix
Avoid read past end of operands vector for EOpFrexp
This commit is contained in:
commit
c92e370e87
@ -2893,9 +2893,11 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
|
|||||||
|
|
||||||
spv::Id id = 0;
|
spv::Id id = 0;
|
||||||
if (libCall >= 0) {
|
if (libCall >= 0) {
|
||||||
while (consumedOperands < (int)operands.size())
|
// Use an extended instruction from the standard library.
|
||||||
operands.pop_back();
|
// Construct the call arguments, without modifying the original operands vector.
|
||||||
id = builder.createBuiltinCall(precision, typeId, stdBuiltins, libCall, operands);
|
// We might need the remaining arguments, e.g. in the EOpFrexp case.
|
||||||
|
std::vector<spv::Id> callArguments(operands.begin(), operands.begin() + consumedOperands);
|
||||||
|
id = builder.createBuiltinCall(precision, typeId, stdBuiltins, libCall, callArguments);
|
||||||
} else {
|
} else {
|
||||||
switch (consumedOperands) {
|
switch (consumedOperands) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -2930,6 +2932,7 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
|
|||||||
builder.createStore(builder.createCompositeExtract(id, typeId0, 1), operands[2]);
|
builder.createStore(builder.createCompositeExtract(id, typeId0, 1), operands[2]);
|
||||||
break;
|
break;
|
||||||
case glslang::EOpFrexp:
|
case glslang::EOpFrexp:
|
||||||
|
assert(operands.size() == 2);
|
||||||
builder.createStore(builder.createCompositeExtract(id, frexpIntType, 1), operands[1]);
|
builder.createStore(builder.createCompositeExtract(id, frexpIntType, 1), operands[1]);
|
||||||
id = builder.createCompositeExtract(id, typeId0, 0);
|
id = builder.createCompositeExtract(id, typeId0, 0);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user