csv: memset the newly allocated struct rather than the first - ploot - simple plotting tools HTML git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 0ee58964da01ae963b4f8d0a906cba93c3095b8b DIR parent f7f88c2ee5573abff4c44c36bf7b2e705081b2ed HTML Author: Josuah Demangeon <me@josuah.net> Date: Sun, 27 Jun 2021 01:04:39 +0200 csv: memset the newly allocated struct rather than the first Diffstat: M csv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- DIR diff --git a/csv.c b/csv.c @@ -96,8 +96,8 @@ csv_labels(FILE *fp, struct csv **vlp, size_t *ncol) while ((field = strsep(&cp, ","))) { if ((vl = realloc(vl, sz += sizeof *vl)) == NULL) err(1, "realloc: %s", strerror(errno)); - memset(vl, 0, sizeof *vl); col = vl + (*ncol)++; + memset(col, 0, sizeof *vl); strlcpy(col->label, field, sizeof col->label); } free(line);