* ts: apply patch of Andy Lindsay (fix one memory leak and PMT handling)