From: Roland Scheidegger Date: Fri, 13 Mar 2015 22:45:20 +0000 (+0100) Subject: gallivm: abort properly when running out of buffer space in lp_disassembly X-Git-Tag: upstream/17.1.0~20035 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2372275d2fc9e4d3785b34a5aeb7b6126e8cc402;p=platform%2Fupstream%2Fmesa.git gallivm: abort properly when running out of buffer space in lp_disassembly Before this actually ran into an infinite loop printing out "invalid"... Reviewed-by: Brian Paul Reviewed-by: Jose Fonseca --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp index 402d29e..2c4ed21 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp @@ -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; }