csv: memset the newly allocated struct rather than the first - ploot - simple p… | |
git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit 0ee58964da01ae963b4f8d0a906cba93c3095b8b | |
parent f7f88c2ee5573abff4c44c36bf7b2e705081b2ed | |
Author: Josuah Demangeon <[email protected]> | |
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(-) | |
--- | |
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); |