aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2021-07-21 12:44:53 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-07-23 11:30:17 -0700
commitc90352008b22819ff903982c96d78bca108a06c4 (patch)
treee8c182abeba1d8b8f78e1530682482b478c0707e /core
parent846e1ba53e32aaeae22b72d4a7843700627f2b27 (diff)
downloadsubsurface-c90352008b22819ff903982c96d78bca108a06c4.tar.gz
core/csv-import: don't do pointer math after realloc
try_to_xslt_open_csv() re-allocates the memory passed in (not really great as far as design goes, maybe something that should be reimplemented). Doing pointer arithmatic with the returned base pointer results in garbage, unless one gets super lucky and the realloc manages to not move the memory. It's a wonder this ever worked. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/import-csv.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/import-csv.c b/core/import-csv.c
index f24c5ec0b..34ac1348b 100644
--- a/core/import-csv.c
+++ b/core/import-csv.c
@@ -245,6 +245,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
return -1;
}
mem_csv.size = ptr - (char*)mem_csv.buffer;
+ end_ptr += ptr - (char *)mem_csv.buffer;
iter = parse_dan_new_line(ptr + 1, NL);
if (iter && strncmp(iter, "ZDT", 3) == 0) {
@@ -268,7 +269,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
return -1;
ret |= parse_xml_buffer(filename, mem_csv.buffer, mem_csv.size, table, trips, sites, devices, filter_presets, params);
- end_ptr += ptr - (char *)mem_csv.buffer;
+
free(mem_csv.buffer);
}