prevent from return if ref_idx is error
Merge pull request #743 from huili2/ec_refidx_return

prevent from return if ref_idx is error