]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
pr: avoid two over-allocations
authorJim Meyering <meyering@redhat.com>
Mon, 18 Jan 2010 06:53:44 +0000 (07:53 +0100)
committerJim Meyering <meyering@redhat.com>
Mon, 18 Jan 2010 11:03:06 +0000 (12:03 +0100)
* src/pr.c (init_store_cols): Allocate N*sizeof(*VAR) bytes,
not N*sizeof(int*).  The latter would mistakenly allocate double
the required space on a system with 8-byte pointers.

src/pr.c

index 1b08894ec448346afa77b1ab046c764bd3003a9e..10770cb569db2f29d9aaae44218572e67f62e05a 100644 (file)
--- a/src/pr.c
+++ b/src/pr.c
@@ -1915,10 +1915,10 @@ init_store_cols (void)
 
   free (line_vector);
   /* FIXME: here's where it was allocated.  */
-  line_vector = xmalloc ((total_lines + 1) * sizeof (int *));
+  line_vector = xmalloc ((total_lines + 1) * sizeof *line_vector);
 
   free (end_vector);
-  end_vector = xmalloc (total_lines * sizeof (int *));
+  end_vector = xmalloc (total_lines * sizeof *end_vector);
 
   free (buff);
   buff_allocated = (use_col_separator