fix array overflow and check preview write status