unexpand: fix incorrect expansion, add test for it
[oweals/busybox.git] / coreutils / cut.c
index 0d95ff84fa2f6b23f42b32108edb3b2266da035f..9cc22be16ef1773c293023a699c87d5ae5f7fa65 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 1999,2000,2001 by Lineo, inc.
  * Written by Mark Whitley <markw@codepoet.org>
- * debloated by Bernhard Fischer
+ * debloated by Bernhard Reutner-Fischer
  *
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
@@ -50,7 +50,7 @@ static void cut_file(FILE *file, char delim, const struct cut_list *cut_lists, u
 
                /* set up a list so we can keep track of what's been printed */
                int linelen = strlen(line);
-               char *printed = xzalloc(linelen * sizeof(char));
+               char *printed = xzalloc(linelen + 1);
                char *orig_line = line;
                unsigned cl_pos = 0;
                int spos;