shithub: puzzles

Download patch

ref: 0a9b0a7384e664126a3af418f047ef627c7ac279
parent: 945d8f0a3a9bfe2702170a75484271c71931b2eb
author: Simon Tatham <anakin@pobox.com>
date: Sat Apr 17 09:27:15 EDT 2010

Fix incorrect uses of ctype.h (passing it uncast chars, or other
things potentially not in the range 0..255).

[originally from svn r8922]

--- a/filling.c
+++ b/filling.c
@@ -1100,7 +1100,7 @@
         button = 0;
         break;
       default:
-        if (!isdigit(button)) return NULL;
+        if (button < '0' || button > '9') return NULL;
         button -= '0';
         if (button > (w == 2 && h == 2? 3: max(w, h))) return NULL;
     }
--- a/magnets.c
+++ b/magnets.c
@@ -386,7 +386,7 @@
 }
 
 static int c2n(char c) { /* XXX cloned from singles.c */
-    if (isdigit(c))
+    if (isdigit((unsigned char)c))
         return (int)(c - '0');
     else if (c >= 'a' && c <= 'z')
         return (int)(c - 'a' + 10);
--- a/signpost.c
+++ b/signpost.c
@@ -513,7 +513,7 @@
         }
 
         c = *desc;
-        if (isdigit(c)) {
+        if (isdigit((unsigned char)c)) {
             num = (num*10) + (int)(c-'0');
             if (num > state->n) {
                 msg = "Number too large";
--- a/singles.c
+++ b/singles.c
@@ -324,7 +324,7 @@
 }
 
 static int c2n(char c) {
-    if (isdigit(c))
+    if (isdigit((unsigned char)c))
         return (int)(c - '0');
     else if (c >= 'a' && c <= 'z')
         return (int)(c - 'a' + 10);