diff mbox series

x86emul: deal with decode failure in predicates test

Message ID aef9579b-f32d-4bc2-8be9-f875605d17a6@suse.com (mailing list archive)
State New, archived
Headers show
Series x86emul: deal with decode failure in predicates test | expand

Commit Message

Jan Beulich Nov. 22, 2023, 7:26 a.m. UTC
Don't let this end in SEGV, due to the subsequent NULL deref.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Andrew Cooper Nov. 22, 2023, 12:03 p.m. UTC | #1
On 22/11/2023 7:26 am, Jan Beulich wrote:
> Don't let this end in SEGV, due to the subsequent NULL deref.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

--- a/tools/tests/x86_emulator/predicates.c
+++ b/tools/tests/x86_emulator/predicates.c
@@ -2189,6 +2189,13 @@  void do_test(uint8_t *instr, unsigned in
     {
         s = x86_decode_insn(ctxt, fetch);
 
+        if ( !s )
+        {
+            print_insn(instr, len);
+            printf(" failed to decode\n");
+            return;
+        }
+
         if ( x86_insn_length(s, ctxt) != len )
         {
             print_insn(instr, len);
@@ -2218,6 +2225,13 @@  void do_test(uint8_t *instr, unsigned in
 
         s = x86_decode_insn(ctxt, fetch);
 
+        if ( !s )
+        {
+            print_insn(instr, len);
+            printf(" failed to decode\n");
+            return;
+        }
+
         if ( x86_insn_length(s, ctxt) != len )
         {
             print_insn(instr, len);