]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/make_hash.c
ncurses 6.0 - patch 20171209
[ncurses.git] / ncurses / tinfo / make_hash.c
index 83e8a6881d07bb710a72cd2d79754367b2babdb9..26d9b834eb2855c8b966634b91b64030af2a7300 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2013,2017 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            *
@@ -44,7 +44,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: make_hash.c,v 1.11 2013/01/26 22:00:11 tom Exp $")
+MODULE_ID("$Id: make_hash.c,v 1.15 2017/10/23 21:19:54 tom Exp $")
 
 /*
  *     _nc_make_hash_table()
@@ -69,10 +69,11 @@ failed(const char *s)
 static char *
 strmalloc(char *s)
 {
-    char *result = malloc(strlen(s) + 1);
+    size_t need = strlen(s) + 1;
+    char *result = malloc(need);
     if (result == 0)
-       failed("strmalloc");
-    strcpy(result, s);
+       failed("strmalloc");
+    _nc_STRCPY(result, s, need);
     return result;
 }
 
@@ -155,7 +156,7 @@ parse_columns(char *buffer)
 
     int col = 0;
 
-    if (list == 0 && (list = typeCalloc(char *, MAX_COLUMNS)) == 0)
+    if (list == 0 && (list = typeCalloc(char *, (MAX_COLUMNS + 1))) == 0)
          return (0);
 
     if (*buffer != '#') {
@@ -325,5 +326,11 @@ main(int argc, char **argv)
     printf("#endif\n\n");
 
     free(hash_table);
+#if NO_LEAKS
+    for (n = 0; (n < CAPTABSIZE); ++n) {
+       free((void *) name_table[n].nte_name);
+    }
+    free(name_table);
+#endif
     return EXIT_SUCCESS;
 }