Avoid undefined pointer given to spvTextDestroy

The undefined pointer might get through to the call
to spvTextDestroy if the test fails on an earlier step.
In that case I just want to see the test failure, and
not a test failure followed by undefined behaviour.
This commit is contained in:
David Neto 2015-09-08 15:38:55 -04:00
parent 26b3b00887
commit 43f0e819c4
2 changed files with 3 additions and 3 deletions

View File

@ -147,7 +147,7 @@ TEST(BinaryToTextSmall, OneInstruction) {
spvTextToBinary(input, strlen(input), opcodeTable, operandTable,
extInstTable, &binary, &diagnostic);
ASSERT_EQ(SPV_SUCCESS, error);
spv_text text;
spv_text text = nullptr;
error = spvBinaryToText(binary->code, binary->wordCount,
SPV_BINARY_TO_TEXT_OPTION_NONE, opcodeTable,
operandTable, extInstTable, &text, &diagnostic);
@ -182,7 +182,7 @@ TEST(BinaryToTextSmall, OperandWithOperands) {
spvTextToBinary(input.str.c_str(), input.str.length(), opcodeTable,
operandTable, extInstTable, &binary, &diagnostic);
ASSERT_EQ(SPV_SUCCESS, error);
spv_text text;
spv_text text = nullptr;
error = spvBinaryToText(binary->code, binary->wordCount,
SPV_BINARY_TO_TEXT_OPTION_NONE, opcodeTable,
operandTable, extInstTable, &text, &diagnostic);

View File

@ -111,7 +111,7 @@ OpFunctionEnd
<< "in\n" << spvtest::WordVector(*binary).str();
// Check round trip gives the same text.
spv_text output_text;
spv_text output_text = nullptr;
error = spvBinaryToText(
binary->code, binary->wordCount, SPV_BINARY_TO_TEXT_OPTION_NONE,
opcodeTable, operandTable, extInstTable, &output_text, &diagnostic);