From 65a3855b98c1ef371d98445a0cfcbb37c4a628e7 Mon Sep 17 00:00:00 2001 From: David Korth Date: Mon, 9 Jun 2025 18:11:03 -0400 Subject: [PATCH] [libromdata] NEResourceReaderPrivate::loadResTbl(): Fix an off-by-one error that broke reading resources from SkiFree 1.0. SkiFree doesn't have any named resources, so its resource table ends immediately after rscEndTypes. The off-by-one prevented us from recognizing the presence of rscEndTypes. SKI.EXE can now be thumbnailed. --- src/libromdata/disc/NEResourceReader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libromdata/disc/NEResourceReader.cpp b/src/libromdata/disc/NEResourceReader.cpp index 75113aa35..c689fd840 100644 --- a/src/libromdata/disc/NEResourceReader.cpp +++ b/src/libromdata/disc/NEResourceReader.cpp @@ -190,13 +190,14 @@ int NEResourceReaderPrivate::loadResTbl(void) int ret = -EIO; while (pos < rsrc_tbl_size) { // Read the next type ID. - if ((pos + 2) >= rsrc_tbl_size) { + if ((pos + 2) > rsrc_tbl_size) { // I/O error; should be at least 2 bytes left... break; } const NE_TYPEINFO *typeInfo = reinterpret_cast(&rsrcTblData[pos]); const uint16_t rtTypeID = le16_to_cpu(typeInfo->rtTypeID); if (rtTypeID == 0) { + // typeInfo is actually pointing to rscEndTypes. // End of rscTypes[]. ret = 0; break;