diff --git a/components/nvs_flash/src/nvs_page.cpp b/components/nvs_flash/src/nvs_page.cpp index 55aa8b66cc4..6797e5a792b 100644 --- a/components/nvs_flash/src/nvs_page.cpp +++ b/components/nvs_flash/src/nvs_page.cpp @@ -1255,7 +1255,11 @@ void Page::debugDump() const printf("X\n"); } else if (state == EntryState::WRITTEN) { Item item; - readEntry(i, item); + // Check readEntry: Item() leaves fields uninitialized; printing key/%s on failure is UB. + if (readEntry(i, item) != ESP_OK) { + printf("Failed to read entry\n"); + return; + } if (skip == 0) { printf("W ns=%2" PRIu8 " type=%2" PRIu8 " span=%3" PRIu8 " key=\"%s\" chunkIdx=%" PRIu8 " len=%" PRIi32 "\n", item.nsIndex, static_cast(item.datatype), item.span, item.key, item.chunkIndex, (item.span != 1) ? (static_cast(item.varLength.dataSize)) : (-1));