]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/make_hash.c
ncurses 6.1 - patch 20200118
[ncurses.git] / ncurses / tinfo / make_hash.c
index 09748ee3e1cedcffb93124070b9b3c22adffdedc..11a10546a925853921372d55e50e510584394b5d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2019,2020 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +43,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: make_hash.c,v 1.27 2019/07/20 20:14:46 tom Exp $")
+MODULE_ID("$Id: make_hash.c,v 1.30 2020/01/18 17:02:38 tom Exp $")
 
 /*
  *     _nc_make_hash_table()
@@ -89,7 +89,7 @@ strmalloc(char *s)
  *
  *     Computes the hashing function on the given string.
  *
- *     The current hash function is the sum of each consectutive pair
+ *     The current hash function is the sum of each consecutive pair
  *     of characters, taken as two-byte integers, mod HASHTABSIZE.
  *
  */
@@ -164,13 +164,11 @@ parse_columns(char *buffer)
 
     int col = 0;
 
-#if NO_LEAKS
     if (buffer == 0) {
        free(list);
        list = 0;
        return 0;
     }
-#endif
 
     if (*buffer != '#') {
        if (list == 0) {
@@ -220,11 +218,17 @@ parse_columns(char *buffer)
 static char *
 get_type(int type_mask)
 {
-    static char result[40];
+    static char result[80];
     unsigned n;
     _nc_STRCPY(result, L_PAREN, sizeof(result));
     for (n = 0; n < 3; ++n) {
        if ((1 << n) & type_mask) {
+           size_t want = 5 + strlen(typenames[n]);
+           if (want > sizeof(result)) {
+               fprintf(stderr, "Buffer is not large enough for %s + %s\n",
+                       result, typenames[n]);
+               exit(EXIT_FAILURE);
+           }
            if (result[1])
                _nc_STRCAT(result, "|", sizeof(result));
            _nc_STRCAT(result, "1<<", sizeof(result));
@@ -427,12 +431,11 @@ main(int argc, char **argv)
     }
 
     free(hash_table);
-#if NO_LEAKS
     for (n = 0; (n < tablesize); ++n) {
        free((void *) name_table[n].ute_name);
     }
     free(name_table);
     parse_columns(0);
-#endif
+
     return EXIT_SUCCESS;
 }