From 3468129f5a6dd2ffa680d343c0cd0eb6baf48be7 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 23 Apr 2020 11:47:29 -0700 Subject: [PATCH] fix issue #337 - crash on start with armhf arch Fix "objects[0] class #1 not in order!" panic. The new check to make sure that the elements of objects[] were in ascending order by object class uses a plain 'char' index so -1 to indicate 'no previous value' didn't work on a system using unsigned chars. Verfied by temporarily adding '-funsigned-char' to CFLAGS before and after the revision. Before: panic, after: no panic. Fixes #337 --- doc/fixes37.0 | 1 + src/o_init.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 54e800a04..a92f238bc 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -210,6 +210,7 @@ poison gas clouds located over known but unlit pools were visible as known after the wish parsing change, wishing for "" or for "" worked as intended but wishing for "" (where used the canonical spelling) triggered a crash +fix new "objects[0] class #1 not in order!" panic if plain 'char' is unsigned tty: redraw unexplored locations as S_unexplored rather than after map has been partially overwritten by popup menu or text display tty: previous change resulted in remnants of previous level being shown on diff --git a/src/o_init.c b/src/o_init.c index be169843d..8bce36391 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -108,8 +108,8 @@ boolean domaterial; void init_objects() { - int i, first, last, sum; - char oclass, prevoclass; + int i, first, last, sum, prevoclass; + char oclass; #ifdef TEXTCOLOR #define COPY_OBJ_DESCR(o_dst, o_src) \ o_dst.oc_descr_idx = o_src.oc_descr_idx, o_dst.oc_color = o_src.oc_color @@ -138,7 +138,7 @@ init_objects() * earlier class would involve switching back to a lower class * number after having moved on to one or more other classes. */ - if (oclass < prevoclass) + if ((int) oclass < prevoclass) panic("objects[%d] class #%d not in order!", first, oclass); last = first + 1; @@ -181,7 +181,7 @@ init_objects() if (sum != 1000) error("init-prob error for class %d (%d%%)", oclass, sum); first = last; - prevoclass = oclass; + prevoclass = (int) oclass; } /* extra entry allows deriving the range of a class via bases[class] through bases[class+1]-1 for all classes */