gallivm: abort properly when running out of buffer space in lp_disassembly
authorRoland Scheidegger <sroland@vmware.com>
Fri, 13 Mar 2015 22:45:20 +0000 (23:45 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Mon, 16 Mar 2015 23:46:48 +0000 (00:46 +0100)
Before this actually ran into an infinite loop printing out "invalid"...

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_debug.cpp

index 402d29e9681d52a6236e86fcf0a85980c90a741e..2c4ed21edd42f3a9314bfcad9f9b946a543350df 100644 (file)
@@ -399,19 +399,23 @@ disassemble(const void* func, llvm::raw_ostream & Out)
             break;
          }
       }
+
+      if (pc >= extent) {
+         Out << "disassembly larger than " << extent << "bytes, aborting\n";
+         break;
+      }
    }
 
+   Out << "\n";
+   Out.flush();
+
    /*
     * Print GDB command, useful to verify output.
     */
-
    if (0) {
       _debug_printf("disassemble %p %p\n", bytes, bytes + pc);
    }
 
-   Out << "\n";
-   Out.flush();
-
    return pc;
 }