#!/usr/bin/env ruby1.9

require 'pp'

patterns = [
            /Invalid read of size 1/,
            /Invalid write of size 1/,
            /Invalid read of size 1/,
            /still reachable: [0-9,]+ bytes in 3 blocks/
           ]

lines = STDIN.readlines
pp lines

result = catch(:done) do
  patterns.each do |pat|
    loop do
      throw(:done, false) if lines.size == 0

      line = lines.shift
      if line =~ pat
        STDERR.puts "matched #{pat}"
        break;
      end
    end
  end

  throw(:done, true)
end

exit(result ? 0 : 1)
