Prevent OOB error in rw_i93_sm_read_ndef()

Bug: 122035770
Test: NFC tag reading
Change-Id: Ic006676962578871ad7ce20064226b096aad662f
Merged-In: I053e9f01dc921bab55b5781c83f048d2638d5b87
(cherry picked from commit 61fcf8972501f9897e9e6e0bc37c60e908421e9a)
diff --git a/src/nfc/tags/rw_i93.c b/src/nfc/tags/rw_i93.c
index bd337e1..8b0adbb 100644
--- a/src/nfc/tags/rw_i93.c
+++ b/src/nfc/tags/rw_i93.c
@@ -1776,6 +1776,12 @@
 
   RW_TRACE_DEBUG0("rw_i93_sm_read_ndef ()");
 
+  if (length == 0) {
+    android_errorWriteLog(0x534e4554, "122035770");
+    rw_i93_handle_error(NFC_STATUS_FAILED);
+    return;
+  }
+
   STREAM_TO_UINT8(flags, p);
   length--;