[PATCH libxkbcommon 2/4] When makekeys fails to find a good hash, print error instead of divide-by-zero

Ran Benita ran234 at gmail.com
Sat Feb 25 14:25:48 PST 2012


This matches commit 78a894231ae8ec4959007b6d9b8d2a15d6333a1e from
libX11:
    Signed-off-by: Alan Coopersmith <alan.coopersmith at sun.com>

Signed-off-by: Ran Benita <ran234 at gmail.com>
---
 makekeys/makekeys.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/makekeys/makekeys.c b/makekeys/makekeys.c
index a25a4a6..fdccaf0 100644
--- a/makekeys/makekeys.c
+++ b/makekeys/makekeys.c
@@ -272,6 +272,11 @@ next1:  ;
     printf("#ifndef KS_TABLES_H\n");
     printf("#define KS_TABLES_H\n\n");
     printf("static const unsigned char _XkeyTable[] = {\n");
+    if (z == 0) {
+        fprintf(stderr, "makekeys: failed to find small enough hash!\n"
+                "Try increasing KTNUM in makekeys.c\n");
+        exit(1);
+    }
     printf("0,\n");
     k = 1;
     for (i = 0; i < ksnum; i++) {
@@ -349,6 +354,11 @@ next2:  ;
     }
 
     z = best_z;
+    if (z == 0) {
+        fprintf(stderr, "makekeys: failed to find small enough hash!\n"
+                "Try increasing KTNUM in makekeys.c\n");
+        exit(1);
+    }
     for (i = z; --i >= 0;)
         offsets[i] = 0;
     for (i = 0; i < ksnum; i++) {
-- 
1.7.9.2



More information about the xorg-devel mailing list