aarch64: Fix uninitialised memory
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 3 Dec 2021 11:57:17 +0000 (11:57 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Fri, 3 Dec 2021 11:57:17 +0000 (11:57 +0000)
AARCH64_OPDE_EXPECTED_A_AFTER_B and AARCH64_OPDE_A_SHOULD_FOLLOW_B
are not paired with an error string, but we had an assert that the
error was nonnull.  Previously this assert was testing uninitialised
memory and so could pass or fail arbitrarily.

opcodes/
* aarch64-opc.c (verify_mops_pme_sequence): Initialize the error
field to null for AARCH64_OPDE_EXPECTED_A_AFTER_B and
AARCH64_OPDE_A_SHOULD_FOLLOW_B.
* aarch64-dis.c (print_verifier_notes): Move assert.

opcodes/aarch64-dis.c
opcodes/aarch64-opc.c

index fdb87b4526f7458be1efd41b8da02ef443b72371..c0fb83122af8de1abad8e1f3ded11e8b02b3afd8 100644 (file)
@@ -3386,7 +3386,6 @@ print_verifier_notes (aarch64_operand_error *detail,
   /* The output of the verifier cannot be a fatal error, otherwise the assembly
      would not have succeeded.  We can safely ignore these.  */
   assert (detail->non_fatal);
-  assert (detail->error);
 
   (*info->fprintf_func) (info->stream, "  // note: ");
   switch (detail->kind)
@@ -3405,6 +3404,7 @@ print_verifier_notes (aarch64_operand_error *detail,
       break;
 
     default:
+      assert (detail->error);
       (*info->fprintf_func) (info->stream, "%s", detail->error);
       if (detail->index >= 0)
        (*info->fprintf_func) (info->stream, " at operand %d",
index 49dfe98769a0b90d975ec103c1d5f3b87b279573..7aa37a5f0ab167c36b3b359140fa6bf003d0f011 100644 (file)
@@ -5522,6 +5522,7 @@ verify_mops_pme_sequence (const struct aarch64_inst *inst,
       && prev_insn->opcode != opcode - 1)
     {
       mismatch_detail->kind = AARCH64_OPDE_EXPECTED_A_AFTER_B;
+      mismatch_detail->error = NULL;
       mismatch_detail->index = -1;
       mismatch_detail->data[0].s = prev_insn->opcode[1].name;
       mismatch_detail->data[1].s = prev_insn->opcode->name;
@@ -5534,6 +5535,7 @@ verify_mops_pme_sequence (const struct aarch64_inst *inst,
       if (is_new_section || !prev_insn || prev_insn->opcode != opcode - 1)
        {
          mismatch_detail->kind = AARCH64_OPDE_A_SHOULD_FOLLOW_B;
+         mismatch_detail->error = NULL;
          mismatch_detail->index = -1;
          mismatch_detail->data[0].s = opcode->name;
          mismatch_detail->data[1].s = opcode[-1].name;