clover: fix tgsi compiler crash with invalid src
authorSerge Martin <edb+mesa@sigluy.net>
Mon, 26 Oct 2015 15:53:00 +0000 (16:53 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 26 Nov 2015 13:30:25 +0000 (15:30 +0200)
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/gallium/state_trackers/clover/tgsi/compiler.cpp

index 54cb747e6fb5495fe7cf181ec728b139bd7db1d1..4d056668a22440d19803d5d20d64bbf19ff4d147 100644 (file)
@@ -97,6 +97,11 @@ namespace {
 module
 clover::compile_program_tgsi(const std::string &source, std::string &r_log) {
    const size_t body_pos = source.find("COMP\n");
+   if (body_pos == std::string::npos) {
+      r_log = "invalid source";
+      throw compile_error();
+   }
+
    const char *body = &source[body_pos];
    module m;