From 09aa8de52cb962f1ceebfb1fd44f2c54a924fc5c Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Mon, 22 Jul 2024 21:43:25 -0400 Subject: puzzles: resync with upstream This brings the puzzles source in sync with Simon's branch, commit fd304c5 (from March 2024), with some added Rockbox-specific compatibility changes: https://www.franklinwei.com/git/puzzles/commit/?h=rockbox-devel&id=516830d9d76bdfe64fe5ccf2a9b59c33f5c7c078 There are quite a lot of backend changes, including a new "Mosaic" puzzle. In addition, some new frontend changes were necessary: - New "Preferences" menu to access the user preferences system. - Enabled spacebar input for several games. Change-Id: I94c7df674089c92f32d5f07025f6a1059068af1e --- apps/plugins/puzzles/src/malloc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'apps/plugins/puzzles/src/malloc.c') diff --git a/apps/plugins/puzzles/src/malloc.c b/apps/plugins/puzzles/src/malloc.c index a7fa7c5adc..39bcfac25b 100644 --- a/apps/plugins/puzzles/src/malloc.c +++ b/apps/plugins/puzzles/src/malloc.c @@ -2,16 +2,23 @@ * malloc.c: safe wrappers around malloc, realloc, free, strdup */ +#ifndef NO_STDINT_H +#include +#endif #include #include #include "puzzles.h" /* - * smalloc should guarantee to return a useful pointer - Halibut + * smalloc should guarantee to return a useful pointer - we * can do nothing except die when it's out of memory anyway. */ void *smalloc(size_t size) { void *p; +#ifdef PTRDIFF_MAX + if (size > PTRDIFF_MAX) + fatal("allocation too large"); +#endif p = malloc(size); if (!p) fatal("out of memory"); @@ -32,6 +39,10 @@ void sfree(void *p) { */ void *srealloc(void *p, size_t size) { void *q; +#ifdef PTRDIFF_MAX + if (size > PTRDIFF_MAX) + fatal("allocation too large"); +#endif if (p) { q = realloc(p, size); } else { -- cgit v1.2.3