[binutils-gdb] Fix: Use of uninitialized memory

Nick Clifton nickc@sourceware.org
Mon Sep 18 11:04:31 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cf2ab5ef0b716dea512d85276c484fce758fa5d4

commit cf2ab5ef0b716dea512d85276c484fce758fa5d4
Author: Jacob Navia <jacob@jacob.remcomp.fr>
Date:   Mon Sep 18 12:03:58 2023 +0100

    Fix: Use of uninitialized memory
    
      * config/tc-riscv.c (riscv_ip_hardcode): Fully initialise the allocated riscv_opcode structure.

Diff:
---
 gas/ChangeLog         | 5 +++++
 gas/config/tc-riscv.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 3339c4cadd3..c6e730f5dcd 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2023-09-18  Jacob Navia  <jacob@jacob.remcomp.fr>
+
+	* config/tc-riscv.c (riscv_ip_hardcode): Fully initialise the
+	allocated riscv_opcode structure.
+
 2023-08-17  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
 	* config/tc-bpf.c (check_immediate_overflow): New function.
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index cf6e0d8b015..3b520ad208b 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -3718,7 +3718,7 @@ riscv_ip_hardcode (char *str,
   if (*input_line_pointer != '\0')
     return _("unrecognized values");
 
-  insn = XNEW (struct riscv_opcode);
+  insn = XCNEW (struct riscv_opcode);
   insn->match = values[num - 1];
   create_insn (ip, insn);
   unsigned int bytes = riscv_insn_length (insn->match);


More information about the Binutils-cvs mailing list