Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Saves: a record that cannot grow for want of room stays as it was

Mason Chena122d981bc67
diff --git a/games/common/epsilon_files.h b/games/common/epsilon_files.h
index 2ee4cfaf..c2d13b8e 100644
--- a/games/common/epsilon_files.h
+++ b/games/common/epsilon_files.h
@@ -146,6 +146,8 @@ __attribute__((unused)) static bool ef_write(const char *name, const void *conte
if (total > 0xFFFF) return false;
int at = ef_find(&fs, name, end);
if (at >= 0 && ef_rd16(fs.buf + at) != total) {
+ /* (no room for the new size: the record stays as it was, not removed first and lost) */
+ if ((uint32_t)end - ef_rd16(fs.buf + at) + total + 2 > fs.size) return false;
if (!ef_remove(name)) return false;
end = ef_end(&fs);
at = -1;