NFC: Fix crash on ISO15693-3 save when memory is empty or cannot be read (#4165)

* NFC: Possibly fix ISO15693-3 save crash with no data

* Also prevent malloc(0) if block size or count is 0

---------

Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
WillyJL
2025-03-31 16:59:12 +00:00
committed by GitHub
parent 6962e9ce34
commit 17759a9e4b
3 changed files with 45 additions and 39 deletions

View File

@@ -37,11 +37,13 @@ void nfc_render_iso15693_3_brief(const Iso15693_3Data* data, FuriString* str) {
}
void nfc_render_iso15693_3_system_info(const Iso15693_3Data* data, FuriString* str) {
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_MEMORY) {
const uint16_t block_count = iso15693_3_get_block_count(data);
const uint8_t block_size = iso15693_3_get_block_size(data);
if((data->system_info.flags & ISO15693_3_SYSINFO_FLAG_MEMORY) &&
(block_count > 0 && block_size > 0)) {
furi_string_cat(str, "\e#Memory data\n\e*--------------------\n");
const uint16_t block_count = iso15693_3_get_block_count(data);
const uint8_t block_size = iso15693_3_get_block_size(data);
const uint16_t display_block_count =
MIN(NFC_RENDER_ISO15693_3_MAX_BYTES / block_size, block_count);