aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2018-05-01 17:11:11 +0100
committerTamar Christina <tamar.christina@arm.com>2018-05-01 17:12:58 +0100
commitb3ac5c6c286c5b5c1909628e85754edfb403cf1a (patch)
tree213f9a7268462fb49e4ecc9fae20bdd2aa62a3c6 /opcodes/aarch64-dis.c
parentUpdated Spanish translation for the gas sub-directory. (diff)
downloadbinutils-gdb-b3ac5c6c286c5b5c1909628e85754edfb403cf1a.tar.gz
binutils-gdb-b3ac5c6c286c5b5c1909628e85754edfb403cf1a.tar.bz2
binutils-gdb-b3ac5c6c286c5b5c1909628e85754edfb403cf1a.zip
Fix unintialized memory in aarch64 opcodes.
This patch fixes an issue where the memory for the opcode structure is not zero'd before the first exit branch. So there is one failure mode for which uninitialized memory is returned. This causes weird failures when the return code is not checked before inst is used. opcodes/ * aarch64-dis.c (aarch64_opcode_decode): Moved memory clear code.
Diffstat (limited to 'opcodes/aarch64-dis.c')
-rw-r--r--opcodes/aarch64-dis.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c
index c63f595f682..e7bece9c1ac 100644
--- a/opcodes/aarch64-dis.c
+++ b/opcodes/aarch64-dis.c
@@ -2733,6 +2733,9 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
assert (opcode && inst);
+ /* Clear inst. */
+ memset (inst, '\0', sizeof (aarch64_inst));
+
/* Check the base opcode. */
if ((code & opcode->mask) != (opcode->opcode & opcode->mask))
{
@@ -2740,9 +2743,6 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
goto decode_fail;
}
- /* Clear inst. */
- memset (inst, '\0', sizeof (aarch64_inst));
-
inst->opcode = opcode;
inst->value = code;