Fix potential crash issue to scan other barcode.